Skip to content

Commit

Permalink
Fixes netbox-community#1325: Retain interface attachment when editing…
Browse files Browse the repository at this point in the history
… a circuit termination
  • Loading branch information
jeremystretch committed Jul 10, 2017
1 parent 342c86e commit 7b6d021
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions netbox/circuits/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ def __init__(self, *args, **kwargs):
super(CircuitTerminationForm, self).__init__(*args, **kwargs)

# Mark connected interfaces as disabled
self.fields['interface'].choices = [
(iface.id, {'label': iface.name, 'disabled': iface.is_connected}) for iface in self.fields['interface'].queryset
]
self.fields['interface'].choices = []
for iface in self.fields['interface'].queryset:
self.fields['interface'].choices.append(
(iface.id, {
'label': iface.name,
'disabled': iface.is_connected and iface.pk != self.initial.get('interface'),
})
)

0 comments on commit 7b6d021

Please sign in to comment.