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

Closes #13149: Wrap form field labels with gettext_lazy()

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Arthur Hanson
2023-07-31 23:52:38 +07:00
committed by GitHub
parent 83bebc1bd2
commit b7a9649269
51 changed files with 1381 additions and 601 deletions

View File

@ -1,5 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from dcim.choices import LinkStatusChoices
from ipam.models import VLAN
@ -20,10 +20,12 @@ __all__ = (
class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
parent = DynamicModelChoiceField(
label=_('Parent'),
queryset=WirelessLANGroup.objects.all(),
required=False
)
description = forms.CharField(
label=_('Description'),
max_length=200,
required=False
)
@ -37,10 +39,12 @@ class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
status = forms.ChoiceField(
label=_('Status'),
choices=add_blank_choice(WirelessLANStatusChoices),
required=False
)
group = DynamicModelChoiceField(
label=_('Group'),
queryset=WirelessLANGroup.objects.all(),
required=False
)
@ -55,14 +59,17 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
label=_('SSID')
)
tenant = DynamicModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False
)
auth_type = forms.ChoiceField(
label=_('Authentication type'),
choices=add_blank_choice(WirelessAuthTypeChoices),
required=False
)
auth_cipher = forms.ChoiceField(
label=_('Authentication cipher'),
choices=add_blank_choice(WirelessAuthCipherChoices),
required=False
)
@ -71,17 +78,16 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
label=_('Pre-shared key')
)
description = forms.CharField(
label=_('Description'),
max_length=200,
required=False
)
comments = CommentField(
label='Comments'
)
comments = CommentField()
model = WirelessLAN
fieldsets = (
(None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
)
nullable_fields = (
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
@ -95,18 +101,22 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
label=_('SSID')
)
status = forms.ChoiceField(
label=_('Status'),
choices=add_blank_choice(LinkStatusChoices),
required=False
)
tenant = DynamicModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False
)
auth_type = forms.ChoiceField(
label=_('Authentication type'),
choices=add_blank_choice(WirelessAuthTypeChoices),
required=False
)
auth_cipher = forms.ChoiceField(
label=_('Authentication cipher'),
choices=add_blank_choice(WirelessAuthCipherChoices),
required=False
)
@ -115,17 +125,16 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
label=_('Pre-shared key')
)
description = forms.CharField(
label=_('Description'),
max_length=200,
required=False
)
comments = CommentField(
label='Comments'
)
comments = CommentField()
model = WirelessLink
fieldsets = (
(None, ('ssid', 'status', 'tenant', 'description')),
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk'))
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk'))
)
nullable_fields = (
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',

View File

@ -1,4 +1,4 @@
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from dcim.choices import LinkStatusChoices
from dcim.models import Interface
@ -18,6 +18,7 @@ __all__ = (
class WirelessLANGroupImportForm(NetBoxModelImportForm):
parent = CSVModelChoiceField(
label=_('Parent'),
queryset=WirelessLANGroup.objects.all(),
required=False,
to_field_name='name',
@ -32,33 +33,39 @@ class WirelessLANGroupImportForm(NetBoxModelImportForm):
class WirelessLANImportForm(NetBoxModelImportForm):
group = CSVModelChoiceField(
label=_('Group'),
queryset=WirelessLANGroup.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned group')
)
status = CSVChoiceField(
label=_('Status'),
choices=WirelessLANStatusChoices,
help_text='Operational status'
)
vlan = CSVModelChoiceField(
label=_('VLAN'),
queryset=VLAN.objects.all(),
required=False,
to_field_name='name',
help_text=_('Bridged VLAN')
)
tenant = CSVModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned tenant')
)
auth_type = CSVChoiceField(
label=_('Authentication type'),
choices=WirelessAuthTypeChoices,
required=False,
help_text=_('Authentication type')
)
auth_cipher = CSVChoiceField(
label=_('Authentication cipher'),
choices=WirelessAuthCipherChoices,
required=False,
help_text=_('Authentication cipher')
@ -74,27 +81,33 @@ class WirelessLANImportForm(NetBoxModelImportForm):
class WirelessLinkImportForm(NetBoxModelImportForm):
status = CSVChoiceField(
label=_('Status'),
choices=LinkStatusChoices,
help_text=_('Connection status')
)
interface_a = CSVModelChoiceField(
label=_('Interface A'),
queryset=Interface.objects.all()
)
interface_b = CSVModelChoiceField(
label=_('Interface B'),
queryset=Interface.objects.all()
)
tenant = CSVModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text=_('Assigned tenant')
)
auth_type = CSVChoiceField(
label=_('Authentication type'),
choices=WirelessAuthTypeChoices,
required=False,
help_text=_('Authentication type')
)
auth_cipher = CSVChoiceField(
label=_('Authentication cipher'),
choices=WirelessAuthCipherChoices,
required=False,
help_text=_('Authentication cipher')

View File

@ -1,5 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from dcim.choices import LinkStatusChoices
from netbox.forms import NetBoxModelFilterSetForm
@ -30,9 +30,9 @@ 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')),
(_('Attributes'), ('ssid', 'group_id', 'status')),
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
)
ssid = forms.CharField(
required=False,
@ -45,18 +45,22 @@ class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
label=_('Group')
)
status = forms.ChoiceField(
label=_('Status'),
required=False,
choices=add_blank_choice(WirelessLANStatusChoices)
)
auth_type = forms.ChoiceField(
label=_('Authentication type'),
required=False,
choices=add_blank_choice(WirelessAuthTypeChoices)
)
auth_cipher = forms.ChoiceField(
label=_('Authentication cipher'),
required=False,
choices=add_blank_choice(WirelessAuthCipherChoices)
)
auth_psk = forms.CharField(
label=_('Pre-shared key'),
required=False
)
tag = TagFilterField(model)
@ -66,27 +70,31 @@ 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')),
(_('Attributes'), ('ssid', 'status',)),
(_('Tenant'), ('tenant_group_id', 'tenant_id')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
)
ssid = forms.CharField(
required=False,
label=_('SSID')
)
status = forms.ChoiceField(
label=_('Status'),
required=False,
choices=add_blank_choice(LinkStatusChoices)
)
auth_type = forms.ChoiceField(
label=_('Authentication type'),
required=False,
choices=add_blank_choice(WirelessAuthTypeChoices)
)
auth_cipher = forms.ChoiceField(
label=_('Authentication cipher'),
required=False,
choices=add_blank_choice(WirelessAuthCipherChoices)
)
auth_psk = forms.CharField(
label=_('Pre-shared key'),
required=False
)
tag = TagFilterField(model)

View File

@ -1,5 +1,5 @@
from django.forms import PasswordInput
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from dcim.models import Device, Interface, Location, Site
from ipam.models import VLAN
@ -17,13 +17,14 @@ __all__ = (
class WirelessLANGroupForm(NetBoxModelForm):
parent = DynamicModelChoiceField(
label=_('Parent'),
queryset=WirelessLANGroup.objects.all(),
required=False
)
slug = SlugField()
fieldsets = (
('Wireless LAN Group', (
(_('Wireless LAN Group'), (
'parent', 'name', 'slug', 'description', 'tags',
)),
)
@ -37,6 +38,7 @@ class WirelessLANGroupForm(NetBoxModelForm):
class WirelessLANForm(TenancyForm, NetBoxModelForm):
group = DynamicModelChoiceField(
label=_('Group'),
queryset=WirelessLANGroup.objects.all(),
required=False
)
@ -49,9 +51,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')),
(_('Wireless LAN'), ('ssid', 'group', 'vlan', 'status', 'description', 'tags')),
(_('Tenancy'), ('tenant_group', 'tenant')),
(_('Authentication'), ('auth_type', 'auth_cipher', 'auth_psk')),
)
class Meta:
@ -152,11 +154,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')),
(_('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')),
)
class Meta: