Skip to content

Commit

Permalink
Fix for bulk interface edit form 802.1Q settings (#1882)
Browse files Browse the repository at this point in the history
* fixes #1881 - bulk interface 802.1Q settings form

* fix PEP8 newline

* PEP8 fixup
  • Loading branch information
lampwins authored and jeremystretch committed Feb 14, 2018
1 parent b2c5bcd commit 28ea06a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,11 @@ def __init__(self, *args, **kwargs):
device = Device.objects.get(pk=self.initial.get('device'))
except Device.DoesNotExist:
pass
else:
try:
device = Device.objects.get(pk=self.data.get('device'))
except Device.DoesNotExist:
pass
if device is not None:
interface_ordering = device.device_type.interface_ordering
self.fields['lag'].queryset = Interface.objects.order_naturally(method=interface_ordering).filter(
Expand All @@ -1950,10 +1955,16 @@ def __init__(self, *args, **kwargs):
self.fields['site'].queryset = Site.objects.none()
self.fields['site'].initial = None

filter_dict = {
'group_id': None,
'site_id': None,
}
if self.is_bound:
filter_dict = {
'group_id': self.data.get('vlan_group') or None,
'site_id': self.data.get('site') or None,
}
else:
filter_dict = {
'group_id': None,
'site_id': None,
}

self.fields['untagged_vlan'].queryset = VLAN.objects.filter(**filter_dict)
self.fields['tagged_vlans'].queryset = VLAN.objects.filter(**filter_dict)
Expand Down Expand Up @@ -2324,4 +2335,4 @@ def clean_vc_position(self):
if Device.objects.filter(virtual_chassis=self.instance.virtual_chassis, vc_position=vc_position).exists():
raise forms.ValidationError("A virtual chassis member already exists in this position.")

return vc_position
return vc_position

0 comments on commit 28ea06a

Please sign in to comment.