mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Add filters to VLAN selection group
This commit is contained in:
parent
01ba1b8c03
commit
1a374a1669
@ -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 extras.models import Tag
|
||||||
from ipam.models import VLAN
|
from ipam.models import VLAN, VLANGroup
|
||||||
from netbox.forms import NetBoxModelForm
|
from netbox.forms import NetBoxModelForm
|
||||||
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField, StaticSelect
|
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField, StaticSelect
|
||||||
from wireless.models import *
|
from wireless.models import *
|
||||||
@ -31,22 +31,73 @@ class WirelessLANForm(NetBoxModelForm):
|
|||||||
queryset=WirelessLANGroup.objects.all(),
|
queryset=WirelessLANGroup.objects.all(),
|
||||||
required=False
|
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(
|
vlan = DynamicModelChoiceField(
|
||||||
queryset=VLAN.objects.all(),
|
queryset=VLAN.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
label='VLAN'
|
label='VLAN',
|
||||||
|
query_params={
|
||||||
|
'site_id': '$site',
|
||||||
|
'group_id': '$vlan_group',
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('Wireless LAN', ('ssid', 'group', 'description', 'tags')),
|
('Wireless LAN', ('ssid', 'group', 'description', 'tags')),
|
||||||
('VLAN', ('vlan',)),
|
('VLAN', ('region', 'site_group', 'site', 'vlan_group', 'vlan',)),
|
||||||
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = WirelessLAN
|
model = WirelessLAN
|
||||||
fields = [
|
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 = {
|
widgets = {
|
||||||
'auth_type': StaticSelect,
|
'auth_type': StaticSelect,
|
||||||
|
Loading…
Reference in New Issue
Block a user