Commit ad85f38e by Kálmán Viktor

dashboard: filter already added interfaces

parent bbe883da
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<h4>{% trans "This VM doesn't have an IPv6 address!" %}</h4> <h4>{% trans "This VM doesn't have an IPv6 address!" %}</h4>
{% endif %} {% endif %}
</div><!-- /ipv6 --> </div><!-- /ipv6 -->
{% include "dashboard/vm-detail/network-port-add.html" %} {% include "dashboard/vm-detail/_network-port-add.html" %}
</div> </div>
</div> </div>
</div> </div>
...@@ -121,6 +121,9 @@ ...@@ -121,6 +121,9 @@
{% 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>
{% endfor %} {% endfor %}
......
...@@ -154,7 +154,11 @@ class VmDetailView(CheckedDetailView): ...@@ -154,7 +154,11 @@ class VmDetailView(CheckedDetailView):
context['activity'] = ia context['activity'] = ia
context['vlans'] = Vlan.get_objects_with_level( context['vlans'] = Vlan.get_objects_with_level(
'user', self.request.user).all() 'user', self.request.user
).exclude(
pk__in=Interface.objects.filter(
instance=self.get_object()).values_list("vlan", flat=True)
).all()
context['acl'] = get_acl_data(instance) context['acl'] = get_acl_data(instance)
context['forms'] = { context['forms'] = {
'disk_add_form': DiskAddForm(prefix="disk"), 'disk_add_form': DiskAddForm(prefix="disk"),
......
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