|
|
@@ -1240,19 +1240,45 @@ class VLANGroupFilterForm(BootstrapMixin, forms.Form):
|
|
|
#
|
|
|
|
|
|
class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
|
|
|
+ # VLANGroup assignment fields
|
|
|
+ scope_type = forms.ChoiceField(
|
|
|
+ choices=(
|
|
|
+ ('', ''),
|
|
|
+ ('dcim.region', 'Region'),
|
|
|
+ ('dcim.sitegroup', 'Site group'),
|
|
|
+ ('dcim.site', 'Site'),
|
|
|
+ ('dcim.location', 'Location'),
|
|
|
+ ('dcim.rack', 'Rack'),
|
|
|
+ ),
|
|
|
+ required=False,
|
|
|
+ widget=StaticSelect2,
|
|
|
+ label='Group scope'
|
|
|
+ )
|
|
|
+ group = DynamicModelChoiceField(
|
|
|
+ queryset=VLANGroup.objects.all(),
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'scope_type': '$scope_type',
|
|
|
+ },
|
|
|
+ label='VLAN Group'
|
|
|
+ )
|
|
|
+
|
|
|
+ # Site assignment fields
|
|
|
region = DynamicModelChoiceField(
|
|
|
queryset=Region.objects.all(),
|
|
|
required=False,
|
|
|
initial_params={
|
|
|
'sites': '$site'
|
|
|
- }
|
|
|
+ },
|
|
|
+ label='Region'
|
|
|
)
|
|
|
- site_group = DynamicModelChoiceField(
|
|
|
+ sitegroup = DynamicModelChoiceField(
|
|
|
queryset=SiteGroup.objects.all(),
|
|
|
required=False,
|
|
|
initial_params={
|
|
|
'sites': '$site'
|
|
|
- }
|
|
|
+ },
|
|
|
+ label='Site group'
|
|
|
)
|
|
|
site = DynamicModelChoiceField(
|
|
|
queryset=Site.objects.all(),
|
|
|
@@ -1260,51 +1286,11 @@ class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
|
|
|
null_option='None',
|
|
|
query_params={
|
|
|
'region_id': '$region',
|
|
|
- 'group_id': '$site_group',
|
|
|
- }
|
|
|
- )
|
|
|
- location = DynamicModelChoiceField(
|
|
|
- queryset=Location.objects.all(),
|
|
|
- required=False,
|
|
|
- null_option='None',
|
|
|
- query_params={
|
|
|
- 'site_id': '$site',
|
|
|
- }
|
|
|
- )
|
|
|
- rack = DynamicModelChoiceField(
|
|
|
- queryset=Rack.objects.all(),
|
|
|
- required=False,
|
|
|
- null_option='None',
|
|
|
- query_params={
|
|
|
- 'site_id': '$site',
|
|
|
- 'location_id': '$location',
|
|
|
- }
|
|
|
- )
|
|
|
- group_scope = forms.ChoiceField(
|
|
|
- choices=(
|
|
|
- ('', ''),
|
|
|
- ('dcim.region', 'Region'),
|
|
|
- ('dcim.sitegroup', 'Site group'),
|
|
|
- ('dcim.site', 'Site'),
|
|
|
- ('dcim.location', 'Location'),
|
|
|
- ('dcim.rack', 'Rack'),
|
|
|
- ),
|
|
|
- required=False,
|
|
|
- widget=StaticSelect2,
|
|
|
- label='Group scope'
|
|
|
- )
|
|
|
- group = DynamicModelChoiceField(
|
|
|
- queryset=VLANGroup.objects.all(),
|
|
|
- required=False,
|
|
|
- query_params={
|
|
|
- 'scope_type': '$group_scope',
|
|
|
- 'region': '$region',
|
|
|
- 'sitegroup': '$site_group',
|
|
|
- 'site': '$site',
|
|
|
- 'location': '$location',
|
|
|
- 'rack': '$rack',
|
|
|
+ 'group_id': '$sitegroup',
|
|
|
}
|
|
|
)
|
|
|
+
|
|
|
+ # Other fields
|
|
|
role = DynamicModelChoiceField(
|
|
|
queryset=Role.objects.all(),
|
|
|
required=False
|
|
|
@@ -1319,11 +1305,6 @@ class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
|
|
|
fields = [
|
|
|
'site', 'group', 'vid', 'name', 'status', 'role', 'description', 'tenant_group', 'tenant', 'tags',
|
|
|
]
|
|
|
- fieldsets = (
|
|
|
- ('VLAN', ('vid', 'name', 'status', 'role', 'description', 'tags')),
|
|
|
- ('Assignment', ('region', 'site_group', 'site', 'location', 'rack', 'group_scope', 'group')),
|
|
|
- ('Tenancy', ('tenant_group', 'tenant')),
|
|
|
- )
|
|
|
help_texts = {
|
|
|
'site': "Leave blank if this VLAN spans multiple sites",
|
|
|
'group': "VLAN group (optional)",
|