From 98f57f2dbaf0f3e4d686c9ae9377d2ae6c5723ac Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 27 Dec 2022 11:12:25 -0800 Subject: [PATCH 1/7] 11297 have custom field form display content-type instead of model --- netbox/extras/forms/model_forms.py | 1 - 1 file changed, 1 deletion(-) 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(), From b6cd0991172f61a1a0680e39cca2056f32c83d5c Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 27 Dec 2022 16:07:02 -0500 Subject: [PATCH 2/7] Changelog for #11121, #11280 --- docs/release-notes/version-3.4.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index f0134aa83..1d29c14b5 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -6,9 +6,11 @@ * [#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 ### 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 From ae440c9edf62da125eb2dccce36b9c440ef0e99a Mon Sep 17 00:00:00 2001 From: Alef Burzmali Date: Wed, 28 Dec 2022 19:49:06 +0100 Subject: [PATCH 3/7] Fixes #11223 - Accept app_label for reindex --- netbox/extras/management/commands/reindex.py | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) 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 From b7cdbd3d41397c91cf7a6f3ca2c5e90e30b56c96 Mon Sep 17 00:00:00 2001 From: Alef Burzmali Date: Wed, 28 Dec 2022 21:06:11 +0100 Subject: [PATCH 4/7] Fixes #11248 - Reindex only NetBox apps --- netbox/extras/migrations/0083_search.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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): From ccb2966c4ca641aa6eeca658a902319de4c4f123 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 28 Dec 2022 22:54:33 +0100 Subject: [PATCH 5/7] Fixes #11244: Elevations: Filter badge missing (#11321) * Added filter badge in rack elevation * Tweak template context Co-authored-by: Jeremy Stretch --- netbox/dcim/views.py | 1 + netbox/templates/dcim/rack_elevation_list.html | 4 ++++ 2 files changed, 5 insertions(+) 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/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 %} From d41716880536901a6f70cc664e4ae31a640c82b2 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 28 Dec 2022 16:58:04 -0500 Subject: [PATCH 6/7] Changelog for #11223, #11244, #11248 --- docs/release-notes/version-3.4.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 1d29c14b5..fb2eec5dd 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -7,6 +7,9 @@ * [#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 From 08a419ec7ae24df64c80a7c10d99ae2a6d621e80 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 29 Dec 2022 06:04:35 -0800 Subject: [PATCH 7/7] 11271 flag to disable localization (#11323) * 11271 flag to disable localization * 11271 change to remove middleware * 11271 update docs for new var * Update docs/configuration/system.md Co-authored-by: kkthxbye <400797+kkthxbye-code@users.noreply.github.com> Co-authored-by: Jeremy Stretch Co-authored-by: kkthxbye <400797+kkthxbye-code@users.noreply.github.com> --- docs/configuration/system.md | 8 ++++++++ netbox/netbox/configuration_example.py | 3 +++ netbox/netbox/settings.py | 11 +++++++++++ 3 files changed, 22 insertions(+) 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/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