Skip to content

Commit

Permalink
fixes netbox-community#1881 - bulk interface 802.1Q settings form
Browse files Browse the repository at this point in the history
  • Loading branch information
lampwins committed Feb 13, 2018
1 parent b2c5bcd commit f651435
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 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

0 comments on commit f651435

Please sign in to comment.