diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 708cb962a..33e60322d 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -1299,7 +1299,7 @@ class InterfaceBulkEditForm( vdcs = DynamicModelMultipleChoiceField( queryset=VirtualDeviceContext.objects.all(), required=False, - label=_('Virtual Device Contexts'), + label=_('Virtual device contexts'), query_params={ 'device_id': '$device', } diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index 195d2d421..85d2b88bd 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -821,7 +821,7 @@ class InterfaceImportForm(NetBoxModelImportForm): help_text=_('IEEE 802.1Q operational mode (for L2 interfaces)') ) vrf = CSVModelChoiceField( - label=_('Vrf'), + label=_('VRF'), queryset=VRF.objects.all(), required=False, to_field_name='rd', diff --git a/netbox/dcim/forms/common.py b/netbox/dcim/forms/common.py index aa9be0ca3..77543af12 100644 --- a/netbox/dcim/forms/common.py +++ b/netbox/dcim/forms/common.py @@ -61,8 +61,10 @@ class InterfaceCommonForm(forms.Form): if invalid_vlans: raise forms.ValidationError({ - 'tagged_vlans': _("The tagged VLANs ({vlans}) must belong to the same site as " - "the interface's parent device/VM, or they must be global").format(vlans=', '.join(invalid_vlans)) + 'tagged_vlans': _( + "The tagged VLANs ({vlans}) must belong to the same site as the interface's parent device/VM, " + "or they must be global" + ).format(vlans=', '.join(invalid_vlans)) }) @@ -105,7 +107,7 @@ class ModuleCommonForm(forms.Form): # Installing modules with placeholders require that the bay has a position value if MODULE_TOKEN in template.name and not module_bay.position: raise forms.ValidationError( - _("Cannot install module with placeholder values in a module bay with no position defined") + _("Cannot install module with placeholder values in a module bay with no position defined.") ) resolved_name = template.name.replace(MODULE_TOKEN, module_bay.position) @@ -114,12 +116,17 @@ class ModuleCommonForm(forms.Form): # It is not possible to adopt components already belonging to a module if adopt_components and existing_item and existing_item.module: raise forms.ValidationError( - _("Cannot adopt {name} '{resolved_name}' as it already belongs " - "to a module").format(name=template.component_model.__name__, resolved_name=resolved_name) + _("Cannot adopt {name} '{resolved_name}' as it already belongs to a module").format( + name=template.component_model.__name__, + resolved_name=resolved_name + ) ) # If we are not adopting components we error if the component exists if not adopt_components and resolved_name in installed_components: raise forms.ValidationError( - _("{name} - {resolved_name} already exists").format(name=template.component_model.__name__, resolved_name=resolved_name) + _("{name} - {resolved_name} already exists").format( + name=template.component_model.__name__, + resolved_name=resolved_name + ) ) diff --git a/netbox/dcim/forms/formsets.py b/netbox/dcim/forms/formsets.py index 37e3be0b7..0b9d89a5d 100644 --- a/netbox/dcim/forms/formsets.py +++ b/netbox/dcim/forms/formsets.py @@ -17,6 +17,8 @@ class BaseVCMemberFormSet(forms.BaseModelFormSet): vc_position = form.cleaned_data.get('vc_position') if vc_position: if vc_position in vc_position_list: - error_msg = _("A virtual chassis member already exists in position {vc_position}.").format(vc_position=vc_position) + error_msg = _("A virtual chassis member already exists in position {vc_position}.").format( + vc_position=vc_position + ) form.add_error('vc_position', error_msg) vc_position_list.append(vc_position) diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index c791181e9..4bdb19120 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -967,14 +967,12 @@ class InventoryItemTemplateForm(ComponentTemplateForm): required=False ) component_type = ContentTypeChoiceField( - label=_('Component type'), queryset=ContentType.objects.all(), limit_choices_to=MODULAR_COMPONENT_TEMPLATE_MODELS, required=False, widget=forms.HiddenInput ) component_id = forms.IntegerField( - label=_('Component id'), required=False, widget=forms.HiddenInput ) @@ -1099,7 +1097,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm): vdcs = DynamicModelMultipleChoiceField( queryset=VirtualDeviceContext.objects.all(), required=False, - label=_('Virtual Device Contexts'), + label=_('Virtual device contexts'), query_params={ 'device_id': '$device', } diff --git a/netbox/dcim/forms/object_create.py b/netbox/dcim/forms/object_create.py index d0b509f10..b41e63b58 100644 --- a/netbox/dcim/forms/object_create.py +++ b/netbox/dcim/forms/object_create.py @@ -60,8 +60,9 @@ class ComponentCreateForm(forms.Form): value_count = len(self.cleaned_data[field_name]) if self.cleaned_data[field_name] and value_count != pattern_count: raise forms.ValidationError({ - field_name: _('The provided pattern specifies {value_count} values, but {pattern_count} are ' - 'expected.').format(value_count=value_count, pattern_count=pattern_count) + field_name: _( + "The provided pattern specifies {value_count} values, but {pattern_count} are expected." + ).format(value_count=value_count, pattern_count=pattern_count) }, code='label_pattern_mismatch') @@ -225,8 +226,9 @@ class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm): super().__init__(*args, **kwargs) if 'module' in self.fields: - self.fields['name'].help_text += _(' The string {module} will be replaced with the position ' - 'of the assigned module, if any') + self.fields['name'].help_text += _( + "The string {module} will be replaced with the position of the assigned module, if any." + ) class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm): diff --git a/netbox/extras/forms/bulk_edit.py b/netbox/extras/forms/bulk_edit.py index 81f75f160..46bd4d64c 100644 --- a/netbox/extras/forms/bulk_edit.py +++ b/netbox/extras/forms/bulk_edit.py @@ -119,7 +119,7 @@ class ExportTemplateBulkEditForm(BulkEditForm): required=False ) mime_type = forms.CharField( - label=_('Mime type'), + label=_('MIME type'), max_length=50, required=False ) @@ -176,27 +176,27 @@ class WebhookBulkEditForm(BulkEditForm): widget=BulkEditNullBooleanSelect() ) type_create = forms.NullBooleanField( - label=_('Type create'), + label=_('On create'), required=False, widget=BulkEditNullBooleanSelect() ) type_update = forms.NullBooleanField( - label=_('Type update'), + label=_('On update'), required=False, widget=BulkEditNullBooleanSelect() ) type_delete = forms.NullBooleanField( - label=_('Type delete'), + label=_('On delete'), required=False, widget=BulkEditNullBooleanSelect() ) type_job_start = forms.NullBooleanField( - label=_('Type job start'), + label=_('On job start'), required=False, widget=BulkEditNullBooleanSelect() ) type_job_end = forms.NullBooleanField( - label=_('Type job end'), + label=_('On job end'), required=False, widget=BulkEditNullBooleanSelect() ) diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 9f1a018c1..31afbd39d 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -53,7 +53,7 @@ class CustomFieldImportForm(CSVModelForm): help_text=_('Choice set (for selection fields)') ) ui_visibility = CSVChoiceField( - label=_('Ui visitility'), + label=_('UI visibility'), choices=CustomFieldVisibilityChoices, help_text=_('How the custom field is displayed in the user interface') ) diff --git a/netbox/extras/forms/filtersets.py b/netbox/extras/forms/filtersets.py index c79f298ef..5d1d2015e 100644 --- a/netbox/extras/forms/filtersets.py +++ b/netbox/extras/forms/filtersets.py @@ -179,7 +179,7 @@ class ImageAttachmentFilterForm(SavedFiltersMixin, FilterForm): (_('Attributes'), ('content_type_id', 'name',)), ) content_type_id = ContentTypeChoiceField( - label=_('Content type id'), + label=_('Content type'), queryset=ContentType.objects.filter(FeatureQuery('custom_fields').get_query()), required=False ) diff --git a/netbox/ipam/forms/bulk_import.py b/netbox/ipam/forms/bulk_import.py index b6486fa26..9b7c624d2 100644 --- a/netbox/ipam/forms/bulk_import.py +++ b/netbox/ipam/forms/bulk_import.py @@ -140,7 +140,7 @@ class RoleImportForm(NetBoxModelImportForm): class PrefixImportForm(NetBoxModelImportForm): vrf = CSVModelChoiceField( - label=_('Vrf'), + label=_('VRF'), queryset=VRF.objects.all(), to_field_name='name', required=False, @@ -226,7 +226,7 @@ class PrefixImportForm(NetBoxModelImportForm): class IPRangeImportForm(NetBoxModelImportForm): vrf = CSVModelChoiceField( - label=_('Vrf'), + label=_('VRF'), queryset=VRF.objects.all(), to_field_name='name', required=False, @@ -262,7 +262,7 @@ class IPRangeImportForm(NetBoxModelImportForm): class IPAddressImportForm(NetBoxModelImportForm): vrf = CSVModelChoiceField( - label=_('Vrf'), + label=_('VRF'), queryset=VRF.objects.all(), to_field_name='name', required=False, @@ -402,13 +402,13 @@ class VLANGroupImportForm(NetBoxModelImportForm): min_value=VLAN_VID_MIN, max_value=VLAN_VID_MAX, required=False, - label=_('Minimum child VLAN VID (default: {vlan_min})').format(vlan_min=VLAN_VID_MIN) + label=_('Minimum child VLAN VID (default: {minimum})').format(minimum=VLAN_VID_MIN) ) max_vid = forms.IntegerField( min_value=VLAN_VID_MIN, max_value=VLAN_VID_MAX, required=False, - label=_('Maximum child VLAN VID (default: {vlan_min})').format(vlan_min=VLAN_VID_MIN) + label=_('Maximum child VLAN VID (default: {maximum})').format(maximum=VLAN_VID_MIN) ) class Meta: diff --git a/netbox/ipam/forms/filtersets.py b/netbox/ipam/forms/filtersets.py index 89de30f0a..299d70565 100644 --- a/netbox/ipam/forms/filtersets.py +++ b/netbox/ipam/forms/filtersets.py @@ -173,7 +173,6 @@ class PrefixFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm): (_('Tenant'), ('tenant_group_id', 'tenant_id')), ) mask_length__lte = forms.IntegerField( - label=_('Mask length'), widget=forms.HiddenInput() ) within_include = forms.CharField( diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index 730abf4e6..c466e279f 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -375,7 +375,9 @@ class IPAddressForm(TenancyForm, NetBoxModelForm): if address.version == 6 and address.prefixlen not in (127, 128): raise ValidationError(msg) if address.version == 4 and address.ip == address.broadcast and address.prefixlen not in (31, 32): - msg = _("{address} is a broadcast address, which may not be assigned to an interface.").format(address=address) + msg = _("{address} is a broadcast address, which may not be assigned to an interface.").format( + address=address + ) raise ValidationError(msg) def save(self, *args, **kwargs): diff --git a/netbox/utilities/forms/fields/array.py b/netbox/utilities/forms/fields/array.py index 1c8c08b32..14f122453 100644 --- a/netbox/utilities/forms/fields/array.py +++ b/netbox/utilities/forms/fields/array.py @@ -13,8 +13,9 @@ class NumericArrayField(SimpleArrayField): def clean(self, value): if value and not self.to_python(value): - raise forms.ValidationError(_('Invalid list ({value}). ' - 'Must be numeric and ranges must be in ascending order').format(value=value)) + raise forms.ValidationError( + _("Invalid list ({value}). Must be numeric and ranges must be in ascending order.").format(value=value) + ) return super().clean(value) def to_python(self, value): diff --git a/netbox/utilities/forms/fields/expandable.py b/netbox/utilities/forms/fields/expandable.py index 61dbd5f72..959271a85 100644 --- a/netbox/utilities/forms/fields/expandable.py +++ b/netbox/utilities/forms/fields/expandable.py @@ -21,10 +21,10 @@ class ExpandableNameField(forms.CharField): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if not self.help_text: - self.help_text = _(""" - Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range - are not supported (example: [ge,xe]-0/0/[0-9]). - """) + self.help_text = _( + "Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range are " + "not supported (example: [ge,xe]-0/0/[0-9])." + ) def to_python(self, value): if not value: diff --git a/netbox/wireless/forms/bulk_edit.py b/netbox/wireless/forms/bulk_edit.py index 4d0b8d8b3..43e804345 100644 --- a/netbox/wireless/forms/bulk_edit.py +++ b/netbox/wireless/forms/bulk_edit.py @@ -64,12 +64,12 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm): required=False ) auth_type = forms.ChoiceField( - label=_('Auth type'), + label=_('Authentication type'), choices=add_blank_choice(WirelessAuthTypeChoices), required=False ) auth_cipher = forms.ChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), choices=add_blank_choice(WirelessAuthCipherChoices), required=False ) @@ -111,12 +111,12 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm): required=False ) auth_type = forms.ChoiceField( - label=_('Auth type'), + label=_('Authentication type'), choices=add_blank_choice(WirelessAuthTypeChoices), required=False ) auth_cipher = forms.ChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), choices=add_blank_choice(WirelessAuthCipherChoices), required=False ) diff --git a/netbox/wireless/forms/bulk_import.py b/netbox/wireless/forms/bulk_import.py index 7db64634e..c0e2dfb54 100644 --- a/netbox/wireless/forms/bulk_import.py +++ b/netbox/wireless/forms/bulk_import.py @@ -59,13 +59,13 @@ class WirelessLANImportForm(NetBoxModelImportForm): help_text=_('Assigned tenant') ) auth_type = CSVChoiceField( - label=_('Auth type'), + label=_('Authentication type'), choices=WirelessAuthTypeChoices, required=False, help_text=_('Authentication type') ) auth_cipher = CSVChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), choices=WirelessAuthCipherChoices, required=False, help_text=_('Authentication cipher') @@ -86,11 +86,11 @@ class WirelessLinkImportForm(NetBoxModelImportForm): help_text=_('Connection status') ) interface_a = CSVModelChoiceField( - label=_('Interface a'), + label=_('Interface A'), queryset=Interface.objects.all() ) interface_b = CSVModelChoiceField( - label=_('Interface b'), + label=_('Interface B'), queryset=Interface.objects.all() ) tenant = CSVModelChoiceField( @@ -101,13 +101,13 @@ class WirelessLinkImportForm(NetBoxModelImportForm): help_text=_('Assigned tenant') ) auth_type = CSVChoiceField( - label=_('Auth type'), + label=_('Authentication type'), choices=WirelessAuthTypeChoices, required=False, help_text=_('Authentication type') ) auth_cipher = CSVChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), choices=WirelessAuthCipherChoices, required=False, help_text=_('Authentication cipher') diff --git a/netbox/wireless/forms/filtersets.py b/netbox/wireless/forms/filtersets.py index a4f08ceba..f4c1cb523 100644 --- a/netbox/wireless/forms/filtersets.py +++ b/netbox/wireless/forms/filtersets.py @@ -50,17 +50,17 @@ class WirelessLANFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm): choices=add_blank_choice(WirelessLANStatusChoices) ) auth_type = forms.ChoiceField( - label=_('Auth type'), + label=_('Authentication type'), required=False, choices=add_blank_choice(WirelessAuthTypeChoices) ) auth_cipher = forms.ChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), required=False, choices=add_blank_choice(WirelessAuthCipherChoices) ) auth_psk = forms.CharField( - label=_('Auth psk'), + label=_('Pre-shared key'), required=False ) tag = TagFilterField(model) @@ -84,17 +84,17 @@ class WirelessLinkFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm): choices=add_blank_choice(LinkStatusChoices) ) auth_type = forms.ChoiceField( - label=_('Auth type'), + label=_('Authentication type'), required=False, choices=add_blank_choice(WirelessAuthTypeChoices) ) auth_cipher = forms.ChoiceField( - label=_('Auth cipher'), + label=_('Authentication cipher'), required=False, choices=add_blank_choice(WirelessAuthCipherChoices) ) auth_psk = forms.CharField( - label=_('Auth psk'), + label=_('Pre-shared key'), required=False ) tag = TagFilterField(model)