2021-10-12 12:27:12 -04:00
|
|
|
from django import forms
|
2023-07-31 23:52:38 +07:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2021-10-12 12:27:12 -04:00
|
|
|
|
2021-10-13 14:31:30 -04:00
|
|
|
from dcim.choices import LinkStatusChoices
|
2021-10-12 12:27:12 -04:00
|
|
|
from ipam.models import VLAN
|
2022-01-28 15:48:15 -05:00
|
|
|
from netbox.forms import NetBoxModelBulkEditForm
|
2022-06-27 11:30:52 -04:00
|
|
|
from tenancy.models import Tenant
|
2023-04-14 10:33:53 -04:00
|
|
|
from utilities.forms import add_blank_choice
|
|
|
|
from utilities.forms.fields import CommentField, DynamicModelChoiceField
|
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 *
|
2021-10-12 12:27:12 -04:00
|
|
|
|
|
|
|
__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',
|
2021-10-12 12:27:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
2021-10-13 16:40:12 -04:00
|
|
|
parent = DynamicModelChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Parent'),
|
2021-10-13 16:40:12 -04:00
|
|
|
queryset=WirelessLANGroup.objects.all(),
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
description = forms.CharField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Description'),
|
2021-10-13 16:40:12 -04:00
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = WirelessLANGroup
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
|
|
|
(None, ('parent', 'description')),
|
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = ('parent', 'description')
|
2021-10-13 16:40:12 -04:00
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
|
2022-11-04 13:40:39 -04:00
|
|
|
status = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Status'),
|
2022-11-04 13:40:39 -04:00
|
|
|
choices=add_blank_choice(WirelessLANStatusChoices),
|
|
|
|
required=False
|
|
|
|
)
|
2021-10-13 16:40:12 -04:00
|
|
|
group = DynamicModelChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Group'),
|
2021-10-13 16:40:12 -04:00
|
|
|
queryset=WirelessLANGroup.objects.all(),
|
|
|
|
required=False
|
|
|
|
)
|
2021-10-12 12:27:12 -04:00
|
|
|
vlan = DynamicModelChoiceField(
|
|
|
|
queryset=VLAN.objects.all(),
|
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('VLAN')
|
2021-10-12 12:27:12 -04:00
|
|
|
)
|
2021-10-13 09:46:17 -04:00
|
|
|
ssid = forms.CharField(
|
|
|
|
max_length=SSID_MAX_LENGTH,
|
2022-01-06 08:54:05 -05:00
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('SSID')
|
2021-10-13 09:46:17 -04:00
|
|
|
)
|
2022-06-27 11:30:52 -04:00
|
|
|
tenant = DynamicModelChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Tenant'),
|
2022-06-27 11:30:52 -04:00
|
|
|
queryset=Tenant.objects.all(),
|
|
|
|
required=False
|
|
|
|
)
|
2021-10-20 10:58:15 -04:00
|
|
|
auth_type = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Authentication type'),
|
2022-01-06 08:54:05 -05:00
|
|
|
choices=add_blank_choice(WirelessAuthTypeChoices),
|
2021-10-20 10:58:15 -04:00
|
|
|
required=False
|
|
|
|
)
|
|
|
|
auth_cipher = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Authentication cipher'),
|
2022-01-06 08:54:05 -05:00
|
|
|
choices=add_blank_choice(WirelessAuthCipherChoices),
|
2021-10-20 10:58:15 -04:00
|
|
|
required=False
|
|
|
|
)
|
|
|
|
auth_psk = forms.CharField(
|
2022-01-06 08:54:05 -05:00
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Pre-shared key')
|
2021-10-20 10:58:15 -04:00
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
description = forms.CharField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Description'),
|
2022-11-04 08:28:09 -04:00
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
2023-07-31 23:52:38 +07:00
|
|
|
comments = CommentField()
|
2021-10-13 09:46:17 -04:00
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = WirelessLAN
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
2022-11-04 13:40:39 -04:00
|
|
|
(None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
|
2023-07-31 23:52:38 +07:00
|
|
|
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
|
2022-02-04 09:59:53 -05:00
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
|
2022-01-31 16:15:40 -05:00
|
|
|
)
|
2021-10-13 09:46:17 -04:00
|
|
|
|
|
|
|
|
2022-01-28 15:48:15 -05:00
|
|
|
class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
|
2021-10-13 09:46:17 -04:00
|
|
|
ssid = forms.CharField(
|
|
|
|
max_length=SSID_MAX_LENGTH,
|
2022-01-06 08:54:05 -05:00
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('SSID')
|
2021-10-13 09:46:17 -04:00
|
|
|
)
|
2021-10-13 14:31:30 -04:00
|
|
|
status = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Status'),
|
2022-01-06 08:54:05 -05:00
|
|
|
choices=add_blank_choice(LinkStatusChoices),
|
2021-10-13 14:31:30 -04:00
|
|
|
required=False
|
|
|
|
)
|
2022-06-27 11:30:52 -04:00
|
|
|
tenant = DynamicModelChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Tenant'),
|
2022-06-27 11:30:52 -04:00
|
|
|
queryset=Tenant.objects.all(),
|
|
|
|
required=False
|
|
|
|
)
|
2021-10-20 10:58:15 -04:00
|
|
|
auth_type = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Authentication type'),
|
2022-01-06 08:54:05 -05:00
|
|
|
choices=add_blank_choice(WirelessAuthTypeChoices),
|
2021-10-20 10:58:15 -04:00
|
|
|
required=False
|
|
|
|
)
|
|
|
|
auth_cipher = forms.ChoiceField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Authentication cipher'),
|
2022-01-06 08:54:05 -05:00
|
|
|
choices=add_blank_choice(WirelessAuthCipherChoices),
|
2021-10-20 10:58:15 -04:00
|
|
|
required=False
|
|
|
|
)
|
|
|
|
auth_psk = forms.CharField(
|
2022-01-06 08:54:05 -05:00
|
|
|
required=False,
|
2022-11-03 11:58:26 -07:00
|
|
|
label=_('Pre-shared key')
|
2021-10-20 10:58:15 -04:00
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
description = forms.CharField(
|
2023-07-31 23:52:38 +07:00
|
|
|
label=_('Description'),
|
2022-11-04 08:28:09 -04:00
|
|
|
max_length=200,
|
|
|
|
required=False
|
|
|
|
)
|
2023-07-31 23:52:38 +07:00
|
|
|
comments = CommentField()
|
2021-10-12 12:27:12 -04:00
|
|
|
|
2022-02-01 11:00:18 -05:00
|
|
|
model = WirelessLink
|
2022-02-04 09:59:53 -05:00
|
|
|
fieldsets = (
|
2022-06-27 11:30:52 -04:00
|
|
|
(None, ('ssid', 'status', 'tenant', 'description')),
|
2023-07-31 23:52:38 +07:00
|
|
|
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk'))
|
2022-02-04 09:59:53 -05:00
|
|
|
)
|
2022-01-31 16:15:40 -05:00
|
|
|
nullable_fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
|
2022-01-31 16:15:40 -05:00
|
|
|
)
|