diff --git a/docs/configuration/system.md b/docs/configuration/system.md index 5a7c8bebd..7061274f1 100644 --- a/docs/configuration/system.md +++ b/docs/configuration/system.md @@ -65,6 +65,14 @@ Email is sent from NetBox only for critical events or if configured for [logging --- +## ENABLE_LOCALIZATION + +Default: False + +Determines if localization features are enabled or not. This should only be enabled for development or testing purposes as netbox is not yet fully localized. Turning this on will localize numeric and date formats (overriding what is set for DATE_FORMAT) based on the browser locale as well as translate certain strings from third party modules. + +--- + ## HTTP_PROXIES Default: None diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index f0134aa83..fb2eec5dd 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -6,9 +6,14 @@ * [#9285](https://github.com/netbox-community/netbox/issues/9285) - Enable specifying assigned component during bulk import of inventory items * [#10700](https://github.com/netbox-community/netbox/issues/10700) - Match device name when using modules quick search +* [#11121](https://github.com/netbox-community/netbox/issues/11121) - Add VM resource totals to cluster view +* [#11223](https://github.com/netbox-community/netbox/issues/11223) - `reindex` management command should accept app label without model name +* [#11244](https://github.com/netbox-community/netbox/issues/11244) - Add controls for saved filters to rack elevations list +* [#11248](https://github.com/netbox-community/netbox/issues/11248) - Fix database migration when plugin with search indexer is enabled ### Bug Fixes +* [#11280](https://github.com/netbox-community/netbox/issues/11280) - Fix errant newlines when exporting interfaces with multiple IP addresses assigned * [#11290](https://github.com/netbox-community/netbox/issues/11290) - Correct reporting of scheduled job duration * [#11232](https://github.com/netbox-community/netbox/issues/11232) - Enable partial & regular expression matching for non-string types in global search diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 06a486534..870cbcc18 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -691,6 +691,7 @@ class RackElevationListView(generic.ObjectListView): 'sort_choices': ORDERING_CHOICES, 'rack_face': rack_face, 'filter_form': forms.RackElevationFilterForm(request.GET), + 'model': self.queryset.model, }) diff --git a/netbox/extras/forms/model_forms.py b/netbox/extras/forms/model_forms.py index f9b145803..a21cf21e2 100644 --- a/netbox/extras/forms/model_forms.py +++ b/netbox/extras/forms/model_forms.py @@ -32,7 +32,6 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm): content_types = ContentTypeMultipleChoiceField( queryset=ContentType.objects.all(), limit_choices_to=FeatureQuery('custom_fields'), - label=_('Model(s)') ) object_type = ContentTypeChoiceField( queryset=ContentType.objects.all(), diff --git a/netbox/extras/management/commands/reindex.py b/netbox/extras/management/commands/reindex.py index f519688f8..b601a1ac1 100644 --- a/netbox/extras/management/commands/reindex.py +++ b/netbox/extras/management/commands/reindex.py @@ -27,17 +27,28 @@ class Command(BaseCommand): # Return only indexers for the specified models else: for label in model_names: - try: - app_label, model_name = label.lower().split('.') - except ValueError: + labels = label.lower().split('.') + + # Label specifies an exact model + if len(labels) == 2: + app_label, model_name = labels + try: + idx = registry['search'][f'{app_label}.{model_name}'] + indexers[idx.model] = idx + except KeyError: + raise CommandError(f"No indexer registered for {label}") + + # Label specifies all the models of an app + elif len(labels) == 1: + app_label = labels[0] + '.' + for indexer_label, idx in registry['search'].items(): + if indexer_label.startswith(app_label): + indexers[idx.model] = idx + + else: raise CommandError( - f"Invalid model: {label}. Model names must be in the format .." + f"Invalid model: {label}. Model names must be in the format or .." ) - try: - idx = registry['search'][f'{app_label}.{model_name}'] - indexers[idx.model] = idx - except KeyError: - raise CommandError(f"No indexer registered for {label}") return indexers diff --git a/netbox/extras/migrations/0083_search.py b/netbox/extras/migrations/0083_search.py index 8f67717bb..0c53de638 100644 --- a/netbox/extras/migrations/0083_search.py +++ b/netbox/extras/migrations/0083_search.py @@ -10,7 +10,16 @@ from django.db import migrations, models def reindex(apps, schema_editor): # Build the search index (except during tests) if 'test' not in sys.argv: - management.call_command('reindex') + management.call_command( + 'reindex', + 'circuits', + 'dcim', + 'extras', + 'ipam', + 'tenancy', + 'virtualization', + 'wireless', + ) class Migration(migrations.Migration): diff --git a/netbox/netbox/configuration_example.py b/netbox/netbox/configuration_example.py index f298b35fe..9d9651462 100644 --- a/netbox/netbox/configuration_example.py +++ b/netbox/netbox/configuration_example.py @@ -222,6 +222,9 @@ SESSION_COOKIE_NAME = 'sessionid' # database access.) Note that the user as which NetBox runs must have read and write permissions to this path. SESSION_FILE_PATH = None +# Localization +ENABLE_LOCALIZATION = False + # Time zone (default: UTC) TIME_ZONE = 'UTC' diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index cc0a3c016..3a494093b 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -137,6 +137,7 @@ STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None) STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {}) TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a') TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') +ENABLE_LOCALIZATION = getattr(configuration, 'ENABLE_LOCALIZATION', False) # Check for hard-coded dynamic config parameters for param in PARAMS: @@ -356,6 +357,9 @@ MIDDLEWARE = [ 'django_prometheus.middleware.PrometheusAfterMiddleware', ] +if not ENABLE_LOCALIZATION: + MIDDLEWARE.remove("django.middleware.locale.LocaleMiddleware") + ROOT_URLCONF = 'netbox.urls' TEMPLATES_DIR = BASE_DIR + '/templates' @@ -651,6 +655,13 @@ RQ_QUEUES.update({ queue: RQ_PARAMS for queue in set(QUEUE_MAPPINGS.values()) if queue not in RQ_QUEUES }) +# +# Localization +# + +if not ENABLE_LOCALIZATION: + USE_I18N = False + USE_L10N = False # # Plugins diff --git a/netbox/templates/dcim/rack_elevation_list.html b/netbox/templates/dcim/rack_elevation_list.html index ef22bd9b8..c9d9a248a 100644 --- a/netbox/templates/dcim/rack_elevation_list.html +++ b/netbox/templates/dcim/rack_elevation_list.html @@ -35,6 +35,10 @@ {% block content-wrapper %}
+ {% if filter_form %} + {% applied_filters model filter_form request.GET %} + {% endif %} + {# Rack elevations #}
{% if page %}