1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Adapt BulkEditView to not require a parent object for device components

This commit is contained in:
Jeremy Stretch
2020-02-04 18:08:40 -05:00
parent 3e79b9d26a
commit f805b57778
9 changed files with 31 additions and 36 deletions

View File

@@ -881,6 +881,8 @@ class InterfaceBulkEditForm(BootstrapMixin, BulkEditForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
parent_obj = VirtualMachine.objects.filter(pk=self.initial.get('virtual_machine')).first()
# Limit VLan choices to those in: global vlans, global groups, the current site's group, the current site
vlan_choices = []
global_vlans = VLAN.objects.filter(site=None, group=None)
@@ -892,8 +894,8 @@ class InterfaceBulkEditForm(BootstrapMixin, BulkEditForm):
vlan_choices.append(
(group.name, [(vlan.pk, vlan) for vlan in global_group_vlans])
)
if self.parent_obj.cluster is not None:
site = getattr(self.parent_obj.cluster, 'site', None)
if parent_obj.cluster is not None:
site = getattr(parent_obj.cluster, 'site', None)
if site is not None:
# Add non-grouped site VLANs