1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

134 lines
3.6 KiB
Python
Raw Normal View History

from django import forms
from django.utils.translation import gettext as _
2021-10-13 14:31:30 -04:00
from dcim.choices import LinkStatusChoices
from ipam.models import VLAN
from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallTextarea
2021-10-20 10:58:15 -04:00
from wireless.choices import *
2021-10-13 09:46:17 -04:00
from wireless.constants import SSID_MAX_LENGTH
2021-10-13 14:31:30 -04:00
from wireless.models import *
__all__ = (
2021-10-12 17:02:53 -04:00
'WirelessLANBulkEditForm',
2021-10-13 16:40:12 -04:00
'WirelessLANGroupBulkEditForm',
2021-10-13 09:46:17 -04:00
'WirelessLinkBulkEditForm',
)
class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
2021-10-13 16:40:12 -04:00
parent = DynamicModelChoiceField(
queryset=WirelessLANGroup.objects.all(),
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
model = WirelessLANGroup
fieldsets = (
(None, ('parent', 'description')),
)
nullable_fields = ('parent', 'description')
2021-10-13 16:40:12 -04:00
class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
status = forms.ChoiceField(
choices=add_blank_choice(WirelessLANStatusChoices),
required=False
)
2021-10-13 16:40:12 -04:00
group = DynamicModelChoiceField(
queryset=WirelessLANGroup.objects.all(),
required=False
)
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
label=_('VLAN')
)
2021-10-13 09:46:17 -04:00
ssid = forms.CharField(
max_length=SSID_MAX_LENGTH,
required=False,
label=_('SSID')
2021-10-13 09:46:17 -04:00
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
required=False
)
2021-10-20 10:58:15 -04:00
auth_type = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthTypeChoices),
2021-10-20 10:58:15 -04:00
required=False
)
auth_cipher = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthCipherChoices),
2021-10-20 10:58:15 -04:00
required=False
)
auth_psk = forms.CharField(
required=False,
label=_('Pre-shared key')
2021-10-20 10:58:15 -04:00
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
2021-10-13 09:46:17 -04:00
model = WirelessLAN
fieldsets = (
(None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
)
nullable_fields = (
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
)
2021-10-13 09:46:17 -04:00
class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
2021-10-13 09:46:17 -04:00
ssid = forms.CharField(
max_length=SSID_MAX_LENGTH,
required=False,
label=_('SSID')
2021-10-13 09:46:17 -04:00
)
2021-10-13 14:31:30 -04:00
status = forms.ChoiceField(
choices=add_blank_choice(LinkStatusChoices),
2021-10-13 14:31:30 -04:00
required=False
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
required=False
)
2021-10-20 10:58:15 -04:00
auth_type = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthTypeChoices),
2021-10-20 10:58:15 -04:00
required=False
)
auth_cipher = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthCipherChoices),
2021-10-20 10:58:15 -04:00
required=False
)
auth_psk = forms.CharField(
required=False,
label=_('Pre-shared key')
2021-10-20 10:58:15 -04:00
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = WirelessLink
fieldsets = (
(None, ('ssid', 'status', 'tenant', 'description')),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk'))
)
nullable_fields = (
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
)