Browse Source

Fixes #1927: Include all VC member interaces on A side when creating a new interface connection

Jeremy Stretch 7 years ago
parent
commit
01a97add2a
1 changed files with 6 additions and 4 deletions
  1. 6 4
      netbox/dcim/forms.py

+ 6 - 4
netbox/dcim/forms.py

@@ -2069,7 +2069,7 @@ class InterfaceConnectionForm(BootstrapMixin, ChainedFieldsMixin, forms.ModelFor
         super(InterfaceConnectionForm, self).__init__(*args, **kwargs)
 
         # Initialize interface A choices
-        device_a_interfaces = Interface.objects.connectable().order_naturally().filter(device=device_a).select_related(
+        device_a_interfaces = device_a.vc_interfaces.connectable().order_naturally().select_related(
             'circuit_termination', 'connected_as_a', 'connected_as_b'
         )
         self.fields['interface_a'].choices = [
@@ -2078,9 +2078,11 @@ class InterfaceConnectionForm(BootstrapMixin, ChainedFieldsMixin, forms.ModelFor
 
         # Mark connected interfaces as disabled
         if self.data.get('device_b'):
-            self.fields['interface_b'].choices = [
-                (iface.id, {'label': iface.name, 'disabled': iface.is_connected}) for iface in self.fields['interface_b'].queryset
-            ]
+            self.fields['interface_b'].choices = []
+            for iface in self.fields['interface_b'].queryset:
+                self.fields['interface_b'].choices.append(
+                    (iface.id, {'label': iface.name, 'disabled': iface.is_connected})
+                )
 
 
 class InterfaceConnectionCSVForm(forms.ModelForm):