Commit 4c14305e by Kálmán Viktor

dashboard: if no more networks disabled the button

parent deeeddce
...@@ -121,15 +121,15 @@ ...@@ -121,15 +121,15 @@
{% csrf_token %} {% csrf_token %}
<div class="input-group" style="max-width: 330px;"> <div class="input-group" style="max-width: 330px;">
<select name="new_network_vlan" class="form-control"> <select name="new_network_vlan" class="form-control">
{% if vlans|length == 0 %}
<option value="-1">No more networks!</option>
{% endif %}
{% for v in vlans %} {% for v in vlans %}
<option value="{{ v.pk }}">{{ v.name }}</option> <option value="{{ v.pk }}">{{ v.name }}</option>
{% empty %}
<option value="-1">No more networks!</option>
{% endfor %} {% endfor %}
</select> </select>
<div class="input-group-btn"> <div class="input-group-btn">
<button type="submit" class="btn btn-success"><i class="icon-plus-sign"></i></button> <button {% if vlans|length == 0 %}disabled{% endif %}
type="submit" class="btn btn-success"><i class="icon-plus-sign"></i></button>
</div> </div>
</div> </div>
</form> </form>
......
...@@ -400,7 +400,7 @@ class VmDetailView(CheckedDetailView): ...@@ -400,7 +400,7 @@ class VmDetailView(CheckedDetailView):
if not self.object.has_level(request.user, 'owner'): if not self.object.has_level(request.user, 'owner'):
raise PermissionDenied() raise PermissionDenied()
vlan = Vlan.objects.get(pk=request.POST.get("new_network_vlan")) vlan = get_object_or_404(Vlan, pk=request.POST.get("new_network_vlan"))
if not vlan.has_level(request.user, 'user'): if not vlan.has_level(request.user, 'user'):
raise PermissionDenied() raise PermissionDenied()
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment