From a8a36c0a8fa39250792abeb493ed3065bf0d9fdc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 6 Sep 2023 14:26:19 -0400 Subject: [PATCH 01/35] PRVB --- docs/release-notes/version-3.6.md | 4 ++++ netbox/netbox/settings.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.6.md b/docs/release-notes/version-3.6.md index e9e958a9f..d1cb68532 100644 --- a/docs/release-notes/version-3.6.md +++ b/docs/release-notes/version-3.6.md @@ -1,5 +1,9 @@ # NetBox v3.6 +## v3.6.2 (FUTURE) + +--- + ## v3.6.1 (2023-09-06) ### Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 75099a029..c22281e9e 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -25,7 +25,7 @@ from netbox.constants import RQ_QUEUE_DEFAULT, RQ_QUEUE_HIGH, RQ_QUEUE_LOW # Environment setup # -VERSION = '3.6.1' +VERSION = '3.6.2-dev' # Hostname HOSTNAME = platform.node() From b5125e512fc8a13281381e6822d894a07f94eb11 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 13:52:19 -0400 Subject: [PATCH 02/35] Fixes #13721: Filter VLAN choices by selected site (if any) when creating a prefix --- docs/release-notes/version-3.6.md | 4 ++++ netbox/ipam/forms/model_forms.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/docs/release-notes/version-3.6.md b/docs/release-notes/version-3.6.md index d1cb68532..e0b13f4ae 100644 --- a/docs/release-notes/version-3.6.md +++ b/docs/release-notes/version-3.6.md @@ -2,6 +2,10 @@ ## v3.6.2 (FUTURE) +### Bug Fixes + +* [#13721](https://github.com/netbox-community/netbox/issues/13721) - Filter VLAN choices by selected site (if any) when creating a prefix + --- ## v3.6.1 (2023-09-06) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index c466e279f..cc147cec4 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -215,6 +215,9 @@ class PrefixForm(TenancyForm, NetBoxModelForm): queryset=VLAN.objects.all(), required=False, selector=True, + query_params={ + 'site_id': '$site', + }, label=_('VLAN'), ) role = DynamicModelChoiceField( From 026386db50cd3bff1f1a17c64db07461b369f779 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 14:13:55 -0400 Subject: [PATCH 03/35] Fixes #13706: Restore extra filters dropdown on device interfaces list --- docs/release-notes/version-3.6.md | 1 + netbox/templates/dcim/device/interfaces.html | 4 ++++ netbox/templates/generic/object_children.html | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.6.md b/docs/release-notes/version-3.6.md index e0b13f4ae..71ca249a6 100644 --- a/docs/release-notes/version-3.6.md +++ b/docs/release-notes/version-3.6.md @@ -4,6 +4,7 @@ ### Bug Fixes +* [#13706](https://github.com/netbox-community/netbox/issues/13706) - Restore extra filters dropdown on device interfaces list * [#13721](https://github.com/netbox-community/netbox/issues/13721) - Filter VLAN choices by selected site (if any) when creating a prefix --- diff --git a/netbox/templates/dcim/device/interfaces.html b/netbox/templates/dcim/device/interfaces.html index cab46886b..8b3fe3097 100644 --- a/netbox/templates/dcim/device/interfaces.html +++ b/netbox/templates/dcim/device/interfaces.html @@ -2,6 +2,10 @@ {% load helpers %} {% load i18n %} +{% block table_controls %} + {% include 'dcim/device/inc/interface_table_controls.html' with table_modal="DeviceInterfaceTable_config" %} +{% endblock table_controls %} + {% block bulk_delete_controls %} {{ block.super }} {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} diff --git a/netbox/templates/generic/object_children.html b/netbox/templates/generic/object_children.html index 0fa59d1ec..3e93a7756 100644 --- a/netbox/templates/generic/object_children.html +++ b/netbox/templates/generic/object_children.html @@ -3,7 +3,9 @@ {% load i18n %} {% block content %} - {% include 'inc/table_controls_htmx.html' with table_modal=table_config %} + {% block table_controls %} + {% include 'inc/table_controls_htmx.html' with table_modal=table_config %} + {% endblock table_controls %}
{% csrf_token %}
From 2ffa6d0188862289850ec391769962d3ceb69221 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 14:16:29 -0400 Subject: [PATCH 04/35] Fixes #13701: Correct display of power feed legs under device view --- docs/release-notes/version-3.6.md | 1 + netbox/templates/dcim/device.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.6.md b/docs/release-notes/version-3.6.md index 71ca249a6..a019cbe13 100644 --- a/docs/release-notes/version-3.6.md +++ b/docs/release-notes/version-3.6.md @@ -4,6 +4,7 @@ ### Bug Fixes +* [#13701](https://github.com/netbox-community/netbox/issues/13701) - Correct display of power feed legs under device view * [#13706](https://github.com/netbox-community/netbox/issues/13706) - Restore extra filters dropdown on device interfaces list * [#13721](https://github.com/netbox-community/netbox/issues/13721) - Filter VLAN choices by selected site (if any) when creating a prefix diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index aeab6e399..5fa6a3314 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -296,7 +296,7 @@ {% for leg in utilization.legs %} - {% trans "Leg" context "Leg of a power feed" %} {{ leg }} + {% trans "Leg" context "Leg of a power feed" %} {{ leg.name }} {{ leg.outlet_count }} {{ leg.allocated }} From 75b71890a4bcec91706cd16b9c01c61b65163fe3 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 15:59:50 -0400 Subject: [PATCH 05/35] Misc i18n cleanup --- netbox/core/choices.py | 4 +- netbox/core/data_backends.py | 4 +- netbox/dcim/forms/bulk_import.py | 40 ++++++++++--------- netbox/dcim/models/device_components.py | 21 +++++----- netbox/dcim/models/power.py | 9 ++++- netbox/extras/forms/bulk_import.py | 2 +- netbox/extras/forms/model_forms.py | 10 +++-- netbox/extras/models/configs.py | 4 +- netbox/ipam/models/ip.py | 16 +------- netbox/templates/dcim/cable_trace.html | 6 +-- netbox/templates/dcim/powerfeed.html | 2 +- netbox/templates/exceptions/import_error.html | 15 +++---- .../exceptions/permission_error.html | 6 +-- .../exceptions/programming_error.html | 12 +++--- netbox/templates/generic/bulk_import.html | 2 +- 15 files changed, 77 insertions(+), 76 deletions(-) diff --git a/netbox/core/choices.py b/netbox/core/choices.py index 0067dfed8..b5d9d0d90 100644 --- a/netbox/core/choices.py +++ b/netbox/core/choices.py @@ -14,8 +14,8 @@ class DataSourceTypeChoices(ChoiceSet): CHOICES = ( (LOCAL, _('Local'), 'gray'), - (GIT, _('Git'), 'blue'), - (AMAZON_S3, _('Amazon S3'), 'blue'), + (GIT, 'Git', 'blue'), + (AMAZON_S3, 'Amazon S3', 'blue'), ) diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py index d2dacbbe0..82b3962dd 100644 --- a/netbox/core/data_backends.py +++ b/netbox/core/data_backends.py @@ -81,13 +81,13 @@ class GitBackend(DataBackend): required=False, label=_('Username'), widget=forms.TextInput(attrs={'class': 'form-control'}), - help_text=_("Only used for cloning with HTTP / HTTPS"), + help_text=_("Only used for cloning with HTTP(S)"), ), 'password': forms.CharField( required=False, label=_('Password'), widget=forms.TextInput(attrs={'class': 'form-control'}), - help_text=_("Only used for cloning with HTTP / HTTPS"), + help_text=_("Only used for cloning with HTTP(S)"), ), 'branch': forms.CharField( required=False, diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index a8e75e3c2..74af0696b 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -118,7 +118,9 @@ class SiteImportForm(NetBoxModelImportForm): ) help_texts = { 'time_zone': mark_safe( - _('Time zone (available options)') + '{} ({})'.format( + _('Time zone'), _('available options') + ) ) } @@ -165,7 +167,7 @@ class RackRoleImportForm(NetBoxModelImportForm): model = RackRole fields = ('name', 'slug', 'color', 'description', 'tags') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -375,7 +377,7 @@ class DeviceRoleImportForm(NetBoxModelImportForm): model = DeviceRole fields = ('name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -790,7 +792,9 @@ class InterfaceImportForm(NetBoxModelImportForm): queryset=VirtualDeviceContext.objects.all(), required=False, to_field_name='name', - help_text=_('VDC names separated by commas, encased with double quotes (e.g. "vdc1, vdc2, vdc3")') + help_text=mark_safe( + _('VDC names separated by commas, encased with double quotes. Example:') + ' vdc1,vdc2,vdc3' + ) ) type = CSVChoiceField( label=_('Type'), @@ -1085,7 +1089,7 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm): model = InventoryItemRole fields = ('name', 'slug', 'color', 'description') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -1096,38 +1100,38 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm): class CableImportForm(NetBoxModelImportForm): # Termination A side_a_device = CSVModelChoiceField( - label=_('Side a device'), + label=_('Side A device'), queryset=Device.objects.all(), to_field_name='name', - help_text=_('Side A device') + help_text=_('Device name') ) side_a_type = CSVContentTypeField( - label=_('Side a type'), + label=_('Side A type'), queryset=ContentType.objects.all(), limit_choices_to=CABLE_TERMINATION_MODELS, - help_text=_('Side A type') + help_text=_('Termination type') ) side_a_name = forms.CharField( - label=_('Side a name'), - help_text=_('Side A component name') + label=_('Side A name'), + help_text=_('Termination name') ) # Termination B side_b_device = CSVModelChoiceField( - label=_('Side b device'), + label=_('Side B device'), queryset=Device.objects.all(), to_field_name='name', - help_text=_('Side B device') + help_text=_('Device name') ) side_b_type = CSVContentTypeField( - label=_('Side b type'), + label=_('Side B type'), queryset=ContentType.objects.all(), limit_choices_to=CABLE_TERMINATION_MODELS, - help_text=_('Side B type') + help_text=_('Termination type') ) side_b_name = forms.CharField( - label=_('Side b name'), - help_text=_('Side B component name') + label=_('Side B name'), + help_text=_('Termination name') ) # Cable attributes @@ -1164,7 +1168,7 @@ class CableImportForm(NetBoxModelImportForm): 'status', 'tenant', 'label', 'color', 'length', 'length_unit', 'description', 'comments', 'tags', ] help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } def _clean_side(self, side): diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index e18f25e4f..f42ae5895 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -799,9 +799,9 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd if self.bridge and self.bridge.device != self.device: if self.device.virtual_chassis is None: raise ValidationError({ - 'bridge': _(""" - The selected bridge interface ({bridge}) belongs to a different device - ({device}).""").format(bridge=self.bridge, device=self.bridge.device) + 'bridge': _( + "The selected bridge interface ({bridge}) belongs to a different device ({device})." + ).format(bridge=self.bridge, device=self.bridge.device) }) elif self.bridge.device.virtual_chassis != self.device.virtual_chassis: raise ValidationError({ @@ -889,10 +889,10 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd # Validate untagged VLAN if self.untagged_vlan and self.untagged_vlan.site not in [self.device.site, None]: raise ValidationError({ - 'untagged_vlan': _(""" - The untagged VLAN ({untagged_vlan}) must belong to the same site as the - interface's parent device, or it must be global. - """).format(untagged_vlan=self.untagged_vlan) + 'untagged_vlan': _( + "The untagged VLAN ({untagged_vlan}) must belong to the same site as the interface's parent " + "device, or it must be global." + ).format(untagged_vlan=self.untagged_vlan) }) def save(self, *args, **kwargs): @@ -1067,9 +1067,10 @@ class RearPort(ModularComponentModel, CabledObjectModel, TrackingModelMixin): frontport_count = self.frontports.count() if self.positions < frontport_count: raise ValidationError({ - "positions": _(""" - The number of positions cannot be less than the number of mapped front ports - ({frontport_count})""").format(frontport_count=frontport_count) + "positions": _( + "The number of positions cannot be less than the number of mapped front ports " + "({frontport_count})" + ).format(frontport_count=frontport_count) }) diff --git a/netbox/dcim/models/power.py b/netbox/dcim/models/power.py index 83e5eb23a..a852ea5cd 100644 --- a/netbox/dcim/models/power.py +++ b/netbox/dcim/models/power.py @@ -174,8 +174,13 @@ class PowerFeed(PrimaryModel, PathEndpoint, CabledObjectModel): # Rack must belong to same Site as PowerPanel if self.rack and self.rack.site != self.power_panel.site: - raise ValidationError(_("Rack {} ({}) and power panel {} ({}) are in different sites").format( - self.rack, self.rack.site, self.power_panel, self.power_panel.site + raise ValidationError(_( + "Rack {rack} ({site}) and power panel {powerpanel} ({powerpanel_site}) are in different sites" + ).format( + rack=self.rack, + rack_site=self.rack.site, + powerpanel=self.power_panel, + powerpanel_site=self.power_panel.site )) # AC voltage cannot be negative diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 466baa241..79023a74d 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -164,7 +164,7 @@ class TagImportForm(CSVModelForm): model = Tag fields = ('name', 'slug', 'color', 'description') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } diff --git a/netbox/extras/forms/model_forms.py b/netbox/extras/forms/model_forms.py index d4e59c170..9fa7adb99 100644 --- a/netbox/extras/forms/model_forms.py +++ b/netbox/extras/forms/model_forms.py @@ -4,6 +4,7 @@ from django import forms from django.conf import settings from django.db.models import Q from django.contrib.contenttypes.models import ContentType +from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from core.forms.mixins import SyncedDataMixin @@ -81,7 +82,8 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - # Disable changing the type of a CustomField as it almost universally causes errors if custom field data is already present. + # Disable changing the type of a CustomField as it almost universally causes errors if custom field data + # is already present. if self.instance.pk: self.fields['type'].disabled = True @@ -90,10 +92,10 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm): extra_choices = forms.CharField( widget=ChoicesWidget(), required=False, - help_text=_( + help_text=mark_safe(_( 'Enter one choice per line. An optional label may be specified for each choice by appending it with a ' - 'comma (for example, "choice1,First Choice").' - ) + 'comma. Example:' + ) + ' choice1,First Choice') ) class Meta: diff --git a/netbox/extras/models/configs.py b/netbox/extras/models/configs.py index 47e8dcd82..2acfcb725 100644 --- a/netbox/extras/models/configs.py +++ b/netbox/extras/models/configs.py @@ -146,7 +146,7 @@ class ConfigContext(SyncedDataMixin, CloningMixin, ChangeLoggedModel): # Verify that JSON data is provided as an object if type(self.data) is not dict: raise ValidationError( - {'data': _('JSON data must be in object form. Example: {"foo": 123}')} + {'data': _('JSON data must be in object form. Example:') + ' {"foo": 123}'} ) def sync_data(self): @@ -202,7 +202,7 @@ class ConfigContextModel(models.Model): # Verify that JSON data is provided as an object if self.local_context_data and type(self.local_context_data) is not dict: raise ValidationError( - {'local_context_data': _('JSON data must be in object form. Example: {"foo": 123}')} + {'local_context_data': _('JSON data must be in object form. Example:') + ' {"foo": 123}'} ) diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index 89977704a..2456fa021 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -554,25 +554,13 @@ class IPRange(PrimaryModel): # Check that start & end IP versions match if self.start_address.version != self.end_address.version: raise ValidationError({ - 'end_address': _( - "Ending address version (IPv{end_address_version}) does not match starting address " - "(IPv{start_address_version})" - ).format( - end_address_version=self.end_address.version, - start_address_version=self.start_address.version - ) + 'end_address': _("Starting and ending IP address versions must match") }) # Check that the start & end IP prefix lengths match if self.start_address.prefixlen != self.end_address.prefixlen: raise ValidationError({ - 'end_address': _( - "Ending address mask (/{end_address_prefixlen}) does not match starting address mask " - "(/{start_address_prefixlen})" - ).format( - end_address_prefixlen=self.end_address.prefixlen, - start_address_prefixlen=self.start_address.prefixlen - ) + 'end_address': _("Starting and ending IP address masks must match") }) # Check that the ending address is greater than the starting address diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index 12000f09d..f955c9cf8 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -51,10 +51,10 @@ {% trans "Total length" %} {% if total_length %} - {{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} / - {{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %} + {{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} / + {{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %} {% else %} - {% trans "N/A" %} + {{ ''|placeholder }} {% endif %} diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index ce00f333c..9b791d0e2 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -73,7 +73,7 @@ {% endif %} {% else %} - {% trans "N/A" %} + {{ ''|placeholder }} {% endif %} {% endwith %} diff --git a/netbox/templates/exceptions/import_error.html b/netbox/templates/exceptions/import_error.html index 70896328d..85803da0a 100644 --- a/netbox/templates/exceptions/import_error.html +++ b/netbox/templates/exceptions/import_error.html @@ -7,19 +7,20 @@

+ {% trans "Missing required packages" %}. {% blocktrans %} - Missing required packages. This installation of NetBox might be missing one or more required - Python packages. These packages are listed in requirements.txt and - local_requirements.txt, and are normally installed as part of the installation or upgrade process. - To verify installed packages, run pip freeze from the console and compare the output to the list of - required packages. + This installation of NetBox might be missing one or more required Python packages. These packages are listed in + requirements.txt and local_requirements.txt, and are normally installed as part of the + installation or upgrade process. To verify installed packages, run pip freeze from the console and + compare the output to the list of required packages. {% endblocktrans %}

+ {% trans "WSGI service not restarted after upgrade" %}. {% blocktrans %} - WSGI service not restarted after upgrade. If this installation has recently been upgraded, check - that the WSGI service (e.g. gunicorn or uWSGI) has been restarted. This ensures that the new code is running. + If this installation has recently been upgraded, check that the WSGI service (e.g. gunicorn or uWSGI) has been + restarted. This ensures that the new code is running. {% endblocktrans %}

{% endblock message %} diff --git a/netbox/templates/exceptions/permission_error.html b/netbox/templates/exceptions/permission_error.html index 3df6ad5c8..334c3d0bd 100644 --- a/netbox/templates/exceptions/permission_error.html +++ b/netbox/templates/exceptions/permission_error.html @@ -7,10 +7,10 @@

+ {% trans "Insufficient write permission to the media root" %}. {% blocktrans with media_root=settings.MEDIA_ROOT %} - Insufficient write permission to the media root. The configured media root is - {{ media_root }}. Ensure that the user NetBox runs as has access to write files to all locations - within this path. + The configured media root is {{ media_root }}. Ensure that the user NetBox runs as has access to + write files to all locations within this path. {% endblocktrans %}

{% endblock message %} diff --git a/netbox/templates/exceptions/programming_error.html b/netbox/templates/exceptions/programming_error.html index 5d82e4511..d24378f7c 100644 --- a/netbox/templates/exceptions/programming_error.html +++ b/netbox/templates/exceptions/programming_error.html @@ -7,18 +7,18 @@

+ {% trans "Database migrations missing" %}. {% blocktrans %} - Database migrations missing. When upgrading to a new NetBox release, the upgrade script must be - run to apply any new database migrations. You can run migrations manually by executing - python3 manage.py migrate from the command line. + When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You + can run migrations manually by executing python3 manage.py migrate from the command line. {% endblocktrans %}

+ {% trans "Unsupported PostgreSQL version" %}. {% blocktrans %} - Unsupported PostgreSQL version. Ensure that PostgreSQL version 12 or later is in use. You can - check this by connecting to the database using NetBox's credentials and issuing a query for - SELECT VERSION(). + Ensure that PostgreSQL version 12 or later is in use. You can check this by connecting to the database using + NetBox's credentials and issuing a query for SELECT VERSION(). {% endblocktrans %}

{% endblock message %} diff --git a/netbox/templates/generic/bulk_import.html b/netbox/templates/generic/bulk_import.html index 08f13765c..f7d8aae77 100644 --- a/netbox/templates/generic/bulk_import.html +++ b/netbox/templates/generic/bulk_import.html @@ -177,7 +177,7 @@ Context: {% if field|widget_type == 'dateinput' %} {% trans "Format: YYYY-MM-DD" %} {% elif field|widget_type == 'checkboxinput' %} - {% trans "Specify \"true\" or \"false" %}" + {% trans "Specify true or false" %} {% endif %} From 39cb9c32d6dc0fc0e74b3827d1bc1256b448ac22 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 16:17:02 -0400 Subject: [PATCH 06/35] Clean up blocktrans template tags (i18n) --- docs/development/internationalization.md | 4 ++-- .../circuits/circuit_terminations_swap.html | 10 +++++++--- netbox/templates/dcim/bulk_disconnect.html | 2 +- netbox/templates/dcim/cable_trace.html | 2 +- netbox/templates/dcim/devicebay_delete.html | 10 ++++++++-- netbox/templates/dcim/devicebay_depopulate.html | 4 ++-- .../dcim/devicetype/component_templates.html | 2 +- .../dcim/moduletype/component_templates.html | 2 +- netbox/templates/dcim/rack/base.html | 2 +- netbox/templates/dcim/virtualchassis_add_member.html | 6 +++++- netbox/templates/dcim/virtualchassis_edit.html | 2 +- .../templates/dcim/virtualchassis_remove_member.html | 2 +- netbox/templates/exceptions/import_error.html | 4 ++-- netbox/templates/exceptions/permission_error.html | 2 +- netbox/templates/exceptions/programming_error.html | 4 ++-- netbox/templates/extras/dashboard/reset.html | 12 ++++++++++-- .../extras/dashboard/widgets/bookmarks.html | 2 +- netbox/templates/extras/objectchange.html | 6 +++++- netbox/templates/extras/report_list.html | 2 +- netbox/templates/extras/script_list.html | 4 ++-- netbox/templates/generic/bulk_delete.html | 2 +- netbox/templates/generic/bulk_import.html | 8 ++++++-- netbox/templates/generic/bulk_remove.html | 6 +++--- netbox/templates/generic/object_edit.html | 2 +- netbox/templates/generic/object_list.html | 2 +- netbox/templates/htmx/delete_form.html | 2 +- netbox/templates/inc/missing_prerequisites.html | 2 +- netbox/templates/inc/paginator.html | 2 +- netbox/templates/inc/paginator_htmx.html | 2 +- netbox/templates/media_failure.html | 8 ++++---- .../virtualization/cluster_add_devices.html | 2 +- 31 files changed, 76 insertions(+), 46 deletions(-) diff --git a/docs/development/internationalization.md b/docs/development/internationalization.md index bdc7cbdaa..bebc97470 100644 --- a/docs/development/internationalization.md +++ b/docs/development/internationalization.md @@ -97,7 +97,7 @@ class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable): 1. Ensure translation support is enabled by including `{% load i18n %}` at the top of the template. 2. Use the [`{% trans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#translate-template-tag) tag (short for "translate") to wrap short strings. -3. Longer strings may be enclosed between [`{% blocktrans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#blocktranslate-template-tag) and `{% endblocktrans %}` tags to improve readability and to enable variable replacement. +3. Longer strings may be enclosed between [`{% blocktrans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#blocktranslate-template-tag) and `{% endblocktrans %}` tags to improve readability and to enable variable replacement. (Remember to include the `trimmed` argument to trim whitespace between the tags.) 4. Avoid passing HTML within translated strings where possible, as this can complicate the work needed of human translators to develop message maps. ``` @@ -107,7 +107,7 @@ class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
{% trans "Circuit List" %}
{# A longer string with a context variable #} -{% blocktrans with count=object.circuits.count %} +{% blocktrans trimmed with count=object.circuits.count %} There are {count} circuits. Would you like to continue? {% endblocktrans %} ``` diff --git a/netbox/templates/circuits/circuit_terminations_swap.html b/netbox/templates/circuits/circuit_terminations_swap.html index 7c9094d42..1ddb67bac 100644 --- a/netbox/templates/circuits/circuit_terminations_swap.html +++ b/netbox/templates/circuits/circuit_terminations_swap.html @@ -4,14 +4,18 @@ {% block title %}{% trans "Swap Circuit Terminations" %}{% endblock %} {% block message %} -

{% blocktrans %}Swap these terminations for circuit {{ circuit }}?{% endblocktrans %}

+

+ {% blocktrans trimmed %} + Swap these terminations for circuit {{ circuit }}? + {% endblocktrans %} +

  • {% trans "A side" %}: {% if termination_a %} {{ termination_a.site }} {% if termination_a.interface %}- {{ termination_a.interface.device }} {{ termination_a.interface }}{% endif %} {% else %} - {{ ''|placeholder }} + {% trans "None" %} {% endif %}
  • @@ -19,7 +23,7 @@ {% if termination_z %} {{ termination_z.site }} {% if termination_z.interface %}- {{ termination_z.interface.device }} {{ termination_z.interface }}{% endif %} {% else %} - {{ ''|placeholder }} + {% trans "None" %} {% endif %}
diff --git a/netbox/templates/dcim/bulk_disconnect.html b/netbox/templates/dcim/bulk_disconnect.html index ede0df357..555ed635b 100644 --- a/netbox/templates/dcim/bulk_disconnect.html +++ b/netbox/templates/dcim/bulk_disconnect.html @@ -6,7 +6,7 @@ {% block message %}

- {% blocktrans with count=selected_objects|length %} + {% blocktrans trimmed with count=selected_objects|length %} Are you sure you want to disconnect these {{ count }} {{ obj_type_plural }}? {% endblocktrans %}

diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index f955c9cf8..676f8a3e5 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -3,7 +3,7 @@ {% load i18n %} {% block title %} - {% blocktrans with object_type=object|meta:"verbose_name"|bettertitle %} + {% blocktrans trimmed with object_type=object|meta:"verbose_name"|bettertitle %} Cable Trace for {{ object_type }} {{ object }} {% endblocktrans %} {% endblock %} diff --git a/netbox/templates/dcim/devicebay_delete.html b/netbox/templates/dcim/devicebay_delete.html index 47e2ba545..18f4f6576 100644 --- a/netbox/templates/dcim/devicebay_delete.html +++ b/netbox/templates/dcim/devicebay_delete.html @@ -2,8 +2,14 @@ {% load form_helpers %} {% load i18n %} -{% block title %}{% blocktrans %}Delete device bay {{ devicebay }}?{% endblocktrans %}{% endblock %} +{% block title %} + {% blocktrans %}Delete device bay {{ devicebay }}?{% endblocktrans %} +{% endblock %} {% block message %} -

{% blocktrans %}Are you sure you want to delete this device bay from {{ devicebay.device }}?{% endblocktrans %}

+

+ {% blocktrans trimmed %} + Are you sure you want to delete this device bay from {{ devicebay.device }}? + {% endblocktrans %} +

{% endblock %} diff --git a/netbox/templates/dcim/devicebay_depopulate.html b/netbox/templates/dcim/devicebay_depopulate.html index a0c026800..b094f5993 100644 --- a/netbox/templates/dcim/devicebay_depopulate.html +++ b/netbox/templates/dcim/devicebay_depopulate.html @@ -3,14 +3,14 @@ {% load i18n %} {% block title %} - {% blocktrans with device=device_bay.installed_device %} + {% blocktrans trimmed with device=device_bay.installed_device %} Remove {{ device }} from {{ device_bay }}? {% endblocktrans %} {% endblock %} {% block message %}

- {% blocktrans with device=device_bay.installed_device %} + {% blocktrans trimmed with device=device_bay.installed_device %} Are you sure you want to remove {{ device }} from {{ device_bay }}? {% endblocktrans %}

diff --git a/netbox/templates/dcim/devicetype/component_templates.html b/netbox/templates/dcim/devicetype/component_templates.html index a2dcb6c0e..9a5210762 100644 --- a/netbox/templates/dcim/devicetype/component_templates.html +++ b/netbox/templates/dcim/devicetype/component_templates.html @@ -27,7 +27,7 @@
diff --git a/netbox/templates/dcim/moduletype/component_templates.html b/netbox/templates/dcim/moduletype/component_templates.html index 63cc1bb99..bb54a33f9 100644 --- a/netbox/templates/dcim/moduletype/component_templates.html +++ b/netbox/templates/dcim/moduletype/component_templates.html @@ -27,7 +27,7 @@
diff --git a/netbox/templates/dcim/rack/base.html b/netbox/templates/dcim/rack/base.html index 27ac284a2..2f4eb227c 100644 --- a/netbox/templates/dcim/rack/base.html +++ b/netbox/templates/dcim/rack/base.html @@ -1,7 +1,7 @@ {% extends 'generic/object.html' %} {% load i18n %} -{% block title %}{% blocktrans %}Rack {{ object }}{% endblocktrans %}{% endblock %} +{% block title %}{% trans "Rack" %} {{ object }}{% endblock %} {% block breadcrumbs %} {{ block.super }} diff --git a/netbox/templates/dcim/virtualchassis_add_member.html b/netbox/templates/dcim/virtualchassis_add_member.html index 6f9b24183..ceb2c71b3 100644 --- a/netbox/templates/dcim/virtualchassis_add_member.html +++ b/netbox/templates/dcim/virtualchassis_add_member.html @@ -2,7 +2,11 @@ {% load form_helpers %} {% load i18n %} -{% block title %}{% blocktrans %}Add New Member to Virtual Chassis {{ virtual_chassis }}{% endblocktrans %}{% endblock %} +{% block title %} + {% blocktrans trimmed %} + Add New Member to Virtual Chassis {{ virtual_chassis }} + {% endblocktrans %} +{% endblock %} {% block content %} diff --git a/netbox/templates/dcim/virtualchassis_edit.html b/netbox/templates/dcim/virtualchassis_edit.html index cfc3de2ec..b8f232fc2 100644 --- a/netbox/templates/dcim/virtualchassis_edit.html +++ b/netbox/templates/dcim/virtualchassis_edit.html @@ -4,7 +4,7 @@ {% load i18n %} {% block title %} - {% blocktrans with name=vc_form.instance %} + {% blocktrans trimmed with name=vc_form.instance %} Editing Virtual Chassis {{ name }} {% endblocktrans %} {% endblock %} diff --git a/netbox/templates/dcim/virtualchassis_remove_member.html b/netbox/templates/dcim/virtualchassis_remove_member.html index 520f3d862..363c2b195 100644 --- a/netbox/templates/dcim/virtualchassis_remove_member.html +++ b/netbox/templates/dcim/virtualchassis_remove_member.html @@ -6,7 +6,7 @@ {% block message %}

- {% blocktrans with name=device.virtual_chassis %} + {% blocktrans trimmed with name=device.virtual_chassis %} Are you sure you want to remove {{ device }} from virtual chassis {{ name }}? {% endblocktrans %}

diff --git a/netbox/templates/exceptions/import_error.html b/netbox/templates/exceptions/import_error.html index 85803da0a..1996412e1 100644 --- a/netbox/templates/exceptions/import_error.html +++ b/netbox/templates/exceptions/import_error.html @@ -8,7 +8,7 @@

{% trans "Missing required packages" %}. - {% blocktrans %} + {% blocktrans trimmed %} This installation of NetBox might be missing one or more required Python packages. These packages are listed in requirements.txt and local_requirements.txt, and are normally installed as part of the installation or upgrade process. To verify installed packages, run pip freeze from the console and @@ -18,7 +18,7 @@

{% trans "WSGI service not restarted after upgrade" %}. - {% blocktrans %} + {% blocktrans trimmed %} If this installation has recently been upgraded, check that the WSGI service (e.g. gunicorn or uWSGI) has been restarted. This ensures that the new code is running. {% endblocktrans %} diff --git a/netbox/templates/exceptions/permission_error.html b/netbox/templates/exceptions/permission_error.html index 334c3d0bd..778508117 100644 --- a/netbox/templates/exceptions/permission_error.html +++ b/netbox/templates/exceptions/permission_error.html @@ -8,7 +8,7 @@

{% trans "Insufficient write permission to the media root" %}. - {% blocktrans with media_root=settings.MEDIA_ROOT %} + {% blocktrans trimmed with media_root=settings.MEDIA_ROOT %} The configured media root is {{ media_root }}. Ensure that the user NetBox runs as has access to write files to all locations within this path. {% endblocktrans %} diff --git a/netbox/templates/exceptions/programming_error.html b/netbox/templates/exceptions/programming_error.html index d24378f7c..fdcbcbda0 100644 --- a/netbox/templates/exceptions/programming_error.html +++ b/netbox/templates/exceptions/programming_error.html @@ -8,7 +8,7 @@

{% trans "Database migrations missing" %}. - {% blocktrans %} + {% blocktrans trimmed %} When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You can run migrations manually by executing python3 manage.py migrate from the command line. {% endblocktrans %} @@ -16,7 +16,7 @@

{% trans "Unsupported PostgreSQL version" %}. - {% blocktrans %} + {% blocktrans trimmed %} Ensure that PostgreSQL version 12 or later is in use. You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION(). {% endblocktrans %} diff --git a/netbox/templates/extras/dashboard/reset.html b/netbox/templates/extras/dashboard/reset.html index ceb032c0d..b163cabb7 100644 --- a/netbox/templates/extras/dashboard/reset.html +++ b/netbox/templates/extras/dashboard/reset.html @@ -4,6 +4,14 @@ {% block title %}{% trans "Reset Dashboard" %}?{% endblock %} {% block message %} -

{% blocktrans %}This will remove all configured widgets and restore the default dashboard configuration.{% endblocktrans %}

-

{% blocktrans %}This change affects only your dashboard, and will not impact other users.{% endblocktrans %}

+

+ {% blocktrans trimmed %} + This will remove all configured widgets and restore the default dashboard configuration. + {% endblocktrans %} +

+

+ {% blocktrans trimmed %} + This change affects only your dashboard, and will not impact other users. + {% endblocktrans %} +

{% endblock %} diff --git a/netbox/templates/extras/dashboard/widgets/bookmarks.html b/netbox/templates/extras/dashboard/widgets/bookmarks.html index e8638d20e..80eb6238e 100644 --- a/netbox/templates/extras/dashboard/widgets/bookmarks.html +++ b/netbox/templates/extras/dashboard/widgets/bookmarks.html @@ -11,6 +11,6 @@ {% else %}

- {% blocktrans %}No bookmarks have been added yet.{% endblocktrans %} + {% trans "No bookmarks have been added yet." %}

{% endif %} diff --git a/netbox/templates/extras/objectchange.html b/netbox/templates/extras/objectchange.html index d681ecd75..63f2019ae 100644 --- a/netbox/templates/extras/objectchange.html +++ b/netbox/templates/extras/objectchange.html @@ -153,7 +153,11 @@ {% include 'inc/panel_table.html' with table=related_changes_table heading='Related Changes' panel_class='default' %} {% if related_changes_count > related_changes_table.rows|length %} {% endif %}
diff --git a/netbox/templates/extras/report_list.html b/netbox/templates/extras/report_list.html index 81b5beb3b..49353f9cc 100644 --- a/netbox/templates/extras/report_list.html +++ b/netbox/templates/extras/report_list.html @@ -117,7 +117,7 @@

{% trans "No Reports Found" %}

{% if perms.extras.add_reportmodule %} {% url 'extras:reportmodule_add' as create_report_url %} - {% blocktrans %} + {% blocktrans trimmed %} Get started by creating a report from an uploaded file or data source. {% endblocktrans %} {% endif %} diff --git a/netbox/templates/extras/script_list.html b/netbox/templates/extras/script_list.html index c78aedc1c..fc45bebc7 100644 --- a/netbox/templates/extras/script_list.html +++ b/netbox/templates/extras/script_list.html @@ -41,7 +41,7 @@ {% if not module.scripts %} @@ -91,7 +91,7 @@

{% trans "No Scripts Found" %}

{% if perms.extras.add_scriptmodule %} {% url 'extras:scriptmodule_add' as create_script_url %} - {% blocktrans %} + {% blocktrans trimmed %} Get started by creating a script from an uploaded file or data source. {% endblocktrans %} {% endif %} diff --git a/netbox/templates/generic/bulk_delete.html b/netbox/templates/generic/bulk_delete.html index 58b0e83ee..47aca4171 100644 --- a/netbox/templates/generic/bulk_delete.html +++ b/netbox/templates/generic/bulk_delete.html @@ -24,7 +24,7 @@ Context:

{% trans "Confirm Bulk Deletion" %}


{% trans "Warning" context "Noun" %}: - {% blocktrans with count=table.rows|length type_plural=model|meta:"verbose_name_plural" %} + {% blocktrans trimmed with count=table.rows|length type_plural=model|meta:"verbose_name_plural" %} The following operation will delete {{ count }} {{ type_plural }}. Please carefully review the objects to be deleted and confirm below. {% endblocktrans %} diff --git a/netbox/templates/generic/bulk_import.html b/netbox/templates/generic/bulk_import.html index f7d8aae77..69c98f7ac 100644 --- a/netbox/templates/generic/bulk_import.html +++ b/netbox/templates/generic/bulk_import.html @@ -189,11 +189,15 @@ Context:

- {% blocktrans %}Required fields must be specified for all objects.{% endblocktrans %} + {% blocktrans trimmed %} + Required fields must be specified for all objects. + {% endblocktrans %}

- {% blocktrans with example="vrf.rd" %}Related objects may be referenced by any unique attribute. For example, {{ example }} would identify a VRF by its route distinguisher.{% endblocktrans %} + {% blocktrans trimmed with example="vrf.rd" %} + Related objects may be referenced by any unique attribute. For example, {{ example }} would identify a VRF by its route distinguisher. + {% endblocktrans %}

{% endif %} diff --git a/netbox/templates/generic/bulk_remove.html b/netbox/templates/generic/bulk_remove.html index 2691fbd3a..0c76897db 100644 --- a/netbox/templates/generic/bulk_remove.html +++ b/netbox/templates/generic/bulk_remove.html @@ -12,13 +12,13 @@