Use FieldSet instances for all forms

This commit is contained in:
Jeremy Stretch
2024-03-18 15:08:28 -04:00
parent 2730bd5712
commit c928756396
35 changed files with 800 additions and 757 deletions

View File

@@ -7,6 +7,7 @@ from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import add_blank_choice
from utilities.forms.fields import CommentField, DynamicModelChoiceField
from utilities.forms.rendering import FieldSet
from wireless.choices import *
from wireless.constants import SSID_MAX_LENGTH
from wireless.models import *
@@ -32,7 +33,7 @@ class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
model = WirelessLANGroup
fieldsets = (
(None, ('parent', 'description')),
FieldSet('parent', 'description'),
)
nullable_fields = ('parent', 'description')
@@ -86,8 +87,8 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
model = WirelessLAN
fieldsets = (
(None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
FieldSet('group', 'ssid', 'status', 'vlan', 'tenant', 'description'),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
nullable_fields = (
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
@@ -133,8 +134,8 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
model = WirelessLink
fieldsets = (
(None, ('ssid', 'status', 'tenant', 'description')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk'))
FieldSet('ssid', 'status', 'tenant', 'description'),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication'))
)
nullable_fields = (
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',

View File

@@ -6,6 +6,7 @@ from netbox.forms import NetBoxModelFilterSetForm
from tenancy.forms import TenancyFilterForm
from utilities.forms import add_blank_choice
from utilities.forms.fields import DynamicModelMultipleChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
from wireless.choices import *
from wireless.models import *
@@ -29,10 +30,10 @@ class WirelessLANGroupFilterForm(NetBoxModelFilterSetForm):
class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
model = WirelessLAN
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
(_('Attributes'), ('ssid', 'group_id', 'status')),
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('ssid', 'group_id', 'status', name=_('Attributes')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
ssid = forms.CharField(
required=False,
@@ -69,10 +70,10 @@ class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
class WirelessLinkFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
model = WirelessLink
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
(_('Attributes'), ('ssid', 'status',)),
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('ssid', 'status', name=_('Attributes')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
ssid = forms.CharField(
required=False,

View File

@@ -6,6 +6,7 @@ from ipam.models import VLAN
from netbox.forms import NetBoxModelForm
from tenancy.forms import TenancyForm
from utilities.forms.fields import CommentField, DynamicModelChoiceField, SlugField
from utilities.forms.rendering import FieldSet
from wireless.models import *
__all__ = (
@@ -24,9 +25,7 @@ class WirelessLANGroupForm(NetBoxModelForm):
slug = SlugField()
fieldsets = (
(_('Wireless LAN Group'), (
'parent', 'name', 'slug', 'description', 'tags',
)),
FieldSet('parent', 'name', 'slug', 'description', 'tags', name=_('Wireless LAN Group')),
)
class Meta:
@@ -51,9 +50,9 @@ class WirelessLANForm(TenancyForm, NetBoxModelForm):
comments = CommentField()
fieldsets = (
(_('Wireless LAN'), ('ssid', 'group', 'vlan', 'status', 'description', 'tags')),
(_('Tenancy'), ('tenant_group', 'tenant')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
FieldSet('ssid', 'group', 'vlan', 'status', 'description', 'tags', name=_('Wireless LAN')),
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
class Meta:
@@ -158,11 +157,11 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
comments = CommentField()
fieldsets = (
(_('Side A'), ('site_a', 'location_a', 'device_a', 'interface_a')),
(_('Side B'), ('site_b', 'location_b', 'device_b', 'interface_b')),
(_('Link'), ('status', 'ssid', 'description', 'tags')),
(_('Tenancy'), ('tenant_group', 'tenant')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
FieldSet('site_a', 'location_a', 'device_a', 'interface_a', name=_('Side A')),
FieldSet('site_b', 'location_b', 'device_b', 'interface_b', name=_('Side B')),
FieldSet('status', 'ssid', 'description', 'tags', name=_('Link')),
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
class Meta: