mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add filters to VLAN selection group
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from dcim.models import Device, Interface, Location, Site
|
||||
from dcim.models import Device, Interface, Location, Region, Site, SiteGroup
|
||||
from extras.models import Tag
|
||||
from ipam.models import VLAN
|
||||
from ipam.models import VLAN, VLANGroup
|
||||
from netbox.forms import NetBoxModelForm
|
||||
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField, StaticSelect
|
||||
from wireless.models import *
|
||||
@@ -31,22 +31,73 @@ class WirelessLANForm(NetBoxModelForm):
|
||||
queryset=WirelessLANGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
|
||||
region = DynamicModelChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
required=False,
|
||||
initial_params={
|
||||
'sites': '$site'
|
||||
}
|
||||
)
|
||||
site_group = DynamicModelChoiceField(
|
||||
queryset=SiteGroup.objects.all(),
|
||||
required=False,
|
||||
initial_params={
|
||||
'sites': '$site'
|
||||
}
|
||||
)
|
||||
site = DynamicModelChoiceField(
|
||||
queryset=Site.objects.all(),
|
||||
required=False,
|
||||
null_option='None',
|
||||
query_params={
|
||||
'region_id': '$region',
|
||||
'group_id': '$site_group',
|
||||
}
|
||||
)
|
||||
vlan_group = DynamicModelChoiceField(
|
||||
queryset=VLANGroup.objects.all(),
|
||||
required=False,
|
||||
label='VLAN group',
|
||||
null_option='None',
|
||||
query_params={
|
||||
'site': '$site'
|
||||
},
|
||||
initial_params={
|
||||
'vlans': '$vlan'
|
||||
}
|
||||
)
|
||||
vlan = DynamicModelChoiceField(
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
label='VLAN'
|
||||
label='VLAN',
|
||||
query_params={
|
||||
'site_id': '$site',
|
||||
'group_id': '$vlan_group',
|
||||
}
|
||||
)
|
||||
|
||||
fieldsets = (
|
||||
('Wireless LAN', ('ssid', 'group', 'description', 'tags')),
|
||||
('VLAN', ('vlan',)),
|
||||
('VLAN', ('region', 'site_group', 'site', 'vlan_group', 'vlan',)),
|
||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = WirelessLAN
|
||||
fields = [
|
||||
'ssid', 'group', 'description', 'vlan', 'auth_type', 'auth_cipher', 'auth_psk', 'tags',
|
||||
'ssid',
|
||||
'group',
|
||||
'description',
|
||||
'region',
|
||||
'site_group',
|
||||
'site',
|
||||
'vlan_group',
|
||||
'vlan',
|
||||
'auth_type',
|
||||
'auth_cipher',
|
||||
'auth_psk',
|
||||
'tags',
|
||||
]
|
||||
widgets = {
|
||||
'auth_type': StaticSelect,
|
||||
|
Reference in New Issue
Block a user