mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
Change site field to vlan_site
This commit is contained in:
parent
3a2aa84a5d
commit
51568d48be
@ -177,7 +177,7 @@ class PrefixImportForm(ScopedImportForm, NetBoxModelImportForm):
|
||||
to_field_name='name',
|
||||
help_text=_("VLAN's group (if any)")
|
||||
)
|
||||
site = CSVModelChoiceField(
|
||||
vlan_site = CSVModelChoiceField(
|
||||
label=_('VLAN Site'),
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
@ -207,7 +207,7 @@ class PrefixImportForm(ScopedImportForm, NetBoxModelImportForm):
|
||||
class Meta:
|
||||
model = Prefix
|
||||
fields = (
|
||||
'prefix', 'vrf', 'tenant', 'vlan_group', 'site', 'vlan', 'status', 'role', 'scope_type', 'scope_id',
|
||||
'prefix', 'vrf', 'tenant', 'vlan_group', 'vlan_site', 'vlan', 'status', 'role', 'scope_type', 'scope_id',
|
||||
'is_pool', 'mark_utilized', 'description', 'comments', 'tags',
|
||||
)
|
||||
labels = {
|
||||
@ -220,19 +220,19 @@ class PrefixImportForm(ScopedImportForm, NetBoxModelImportForm):
|
||||
if not data:
|
||||
return
|
||||
|
||||
site = data.get('site')
|
||||
vlan_site = data.get('vlan_site')
|
||||
vlan_group = data.get('vlan_group')
|
||||
|
||||
# Limit VLAN queryset by assigned site and/or group (if specified)
|
||||
query = Q()
|
||||
|
||||
if site:
|
||||
if vlan_site:
|
||||
query |= Q(**{
|
||||
f"site__{self.fields['site'].to_field_name}": site
|
||||
f"site__{self.fields['vlan_site'].to_field_name}": vlan_site
|
||||
})
|
||||
# Don't Forget to include VLANs without a site in the filter
|
||||
query |= Q(**{
|
||||
f"site__{self.fields['site'].to_field_name}__isnull": True
|
||||
f"site__{self.fields['vlan_site'].to_field_name}__isnull": True
|
||||
})
|
||||
|
||||
if vlan_group:
|
||||
|
Loading…
Reference in New Issue
Block a user