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:
@@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.forms import NetBoxModelBulkEditForm
|
||||
from tenancy.choices import ContactPriorityChoices
|
||||
@@ -22,10 +23,12 @@ __all__ = (
|
||||
|
||||
class TenantGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@@ -36,6 +39,7 @@ class TenantGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class TenantBulkEditForm(NetBoxModelBulkEditForm):
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
@@ -53,10 +57,12 @@ class TenantBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Desciption'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@@ -70,6 +76,7 @@ class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
@@ -83,34 +90,39 @@ class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ContactBulkEditForm(NetBoxModelBulkEditForm):
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
title = forms.CharField(
|
||||
label=_('Title'),
|
||||
max_length=100,
|
||||
required=False
|
||||
)
|
||||
phone = forms.CharField(
|
||||
label=_('Phone'),
|
||||
max_length=50,
|
||||
required=False
|
||||
)
|
||||
email = forms.EmailField(
|
||||
label=_('Email'),
|
||||
required=False
|
||||
)
|
||||
address = forms.CharField(
|
||||
label=_('Address'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
link = forms.URLField(
|
||||
label=_('Link'),
|
||||
required=False
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
comments = CommentField(
|
||||
label='Comments'
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
model = Contact
|
||||
fieldsets = (
|
||||
@@ -121,14 +133,17 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
class ContactAssignmentBulkEditForm(NetBoxModelBulkEditForm):
|
||||
contact = DynamicModelChoiceField(
|
||||
label=_('Contact'),
|
||||
queryset=Contact.objects.all(),
|
||||
required=False
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=ContactRole.objects.all(),
|
||||
required=False
|
||||
)
|
||||
priority = forms.ChoiceField(
|
||||
label=_('Priority'),
|
||||
choices=add_blank_choice(ContactPriorityChoices),
|
||||
required=False
|
||||
)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.forms import NetBoxModelImportForm
|
||||
from tenancy.models import *
|
||||
from utilities.forms.fields import CSVContentTypeField, CSVModelChoiceField, SlugField
|
||||
@@ -20,6 +21,7 @@ __all__ = (
|
||||
|
||||
class TenantGroupImportForm(NetBoxModelImportForm):
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -35,6 +37,7 @@ class TenantGroupImportForm(NetBoxModelImportForm):
|
||||
class TenantImportForm(NetBoxModelImportForm):
|
||||
slug = SlugField()
|
||||
group = CSVModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -52,6 +55,7 @@ class TenantImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ContactGroupImportForm(NetBoxModelImportForm):
|
||||
parent = CSVModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
@@ -74,6 +78,7 @@ class ContactRoleImportForm(NetBoxModelImportForm):
|
||||
|
||||
class ContactImportForm(NetBoxModelImportForm):
|
||||
group = CSVModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False,
|
||||
to_field_name='name',
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from extras.utils import FeatureQuery
|
||||
from netbox.forms import NetBoxModelFilterSetForm
|
||||
@@ -84,7 +84,7 @@ class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||
model = ContactAssignment
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id')),
|
||||
('Assignment', ('content_type_id', 'group_id', 'contact_id', 'role_id', 'priority')),
|
||||
(_('Assignment'), ('content_type_id', 'group_id', 'contact_id', 'role_id', 'priority')),
|
||||
)
|
||||
content_type_id = ContentTypeMultipleChoiceField(
|
||||
queryset=ContentType.objects.all(),
|
||||
@@ -108,6 +108,7 @@ class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||
label=_('Role')
|
||||
)
|
||||
priority = forms.MultipleChoiceField(
|
||||
label=_('Priority'),
|
||||
choices=ContactPriorityChoices,
|
||||
required=False
|
||||
)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from tenancy.models import *
|
||||
from utilities.forms.fields import DynamicModelChoiceField, DynamicModelMultipleChoiceField
|
||||
@@ -13,6 +13,7 @@ __all__ = (
|
||||
|
||||
class TenancyForm(forms.Form):
|
||||
tenant_group = DynamicModelChoiceField(
|
||||
label=_('Tenant group'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False,
|
||||
null_option='None',
|
||||
@@ -21,6 +22,7 @@ class TenancyForm(forms.Form):
|
||||
}
|
||||
)
|
||||
tenant = DynamicModelChoiceField(
|
||||
label=_('Tenant'),
|
||||
queryset=Tenant.objects.all(),
|
||||
required=False,
|
||||
query_params={
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.forms import NetBoxModelForm
|
||||
from tenancy.models import *
|
||||
@@ -21,13 +22,14 @@ __all__ = (
|
||||
|
||||
class TenantGroupForm(NetBoxModelForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Tenant Group', (
|
||||
(_('Tenant Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -42,13 +44,14 @@ class TenantGroupForm(NetBoxModelForm):
|
||||
class TenantForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=TenantGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Tenant', ('name', 'slug', 'group', 'description', 'tags')),
|
||||
(_('Tenant'), ('name', 'slug', 'group', 'description', 'tags')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -64,13 +67,14 @@ class TenantForm(NetBoxModelForm):
|
||||
|
||||
class ContactGroupForm(NetBoxModelForm):
|
||||
parent = DynamicModelChoiceField(
|
||||
label=_('Parent'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Contact Group', (
|
||||
(_('Contact Group'), (
|
||||
'parent', 'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -84,7 +88,7 @@ class ContactRoleForm(NetBoxModelForm):
|
||||
slug = SlugField()
|
||||
|
||||
fieldsets = (
|
||||
('Contact Role', (
|
||||
(_('Contact Role'), (
|
||||
'name', 'slug', 'description', 'tags',
|
||||
)),
|
||||
)
|
||||
@@ -96,13 +100,14 @@ class ContactRoleForm(NetBoxModelForm):
|
||||
|
||||
class ContactForm(NetBoxModelForm):
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Contact', ('group', 'name', 'title', 'phone', 'email', 'address', 'link', 'description', 'tags')),
|
||||
(_('Contact'), ('group', 'name', 'title', 'phone', 'email', 'address', 'link', 'description', 'tags')),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -117,6 +122,7 @@ class ContactForm(NetBoxModelForm):
|
||||
|
||||
class ContactAssignmentForm(BootstrapMixin, forms.ModelForm):
|
||||
group = DynamicModelChoiceField(
|
||||
label=_('Group'),
|
||||
queryset=ContactGroup.objects.all(),
|
||||
required=False,
|
||||
initial_params={
|
||||
@@ -124,12 +130,14 @@ class ContactAssignmentForm(BootstrapMixin, forms.ModelForm):
|
||||
}
|
||||
)
|
||||
contact = DynamicModelChoiceField(
|
||||
label=_('Contact'),
|
||||
queryset=Contact.objects.all(),
|
||||
query_params={
|
||||
'group_id': '$group'
|
||||
}
|
||||
)
|
||||
role = DynamicModelChoiceField(
|
||||
label=_('Role'),
|
||||
queryset=ContactRole.objects.all()
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user