From ba12675267af639f6ed47e7873fb091d75dacd29 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 14 Dec 2022 14:24:46 -0500 Subject: [PATCH 01/12] PRVB --- docs/release-notes/version-3.4.md | 4 ++++ netbox/netbox/settings.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 0527fee3fdc..a5c0ea50a31 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -1,5 +1,9 @@ # NetBox v3.4 +## v3.4.1 (FUTURE) + +--- + ## v3.4.0 (2022-12-14) !!! warning "PostgreSQL 11 Required" diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index eb516a8f9f8..8b2d4f24bcd 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -24,7 +24,7 @@ # Environment setup # -VERSION = '3.4.0' +VERSION = '3.4.1-dev' # Hostname HOSTNAME = platform.node() From 77423e7bb14e6141084676c1be7d6ac02fa126b4 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 15 Dec 2022 09:29:56 -0500 Subject: [PATCH 02/12] Fixes #11185: Fix TemplateSyntaxError when viewing custom script results --- docs/release-notes/version-3.4.md | 4 ++++ netbox/templates/extras/htmx/script_result.html | 1 + 2 files changed, 5 insertions(+) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index a5c0ea50a31..bc9c49e2d53 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -2,6 +2,10 @@ ## v3.4.1 (FUTURE) +### Bug Fixes + +* [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results + --- ## v3.4.0 (2022-12-14) diff --git a/netbox/templates/extras/htmx/script_result.html b/netbox/templates/extras/htmx/script_result.html index ca2d278d3a0..fe06b830986 100644 --- a/netbox/templates/extras/htmx/script_result.html +++ b/netbox/templates/extras/htmx/script_result.html @@ -1,3 +1,4 @@ +{% load humanize %} {% load helpers %} {% load log_levels %} From c59d5276644502e3f56634208968f54300177651 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 14 Dec 2022 11:58:44 -0800 Subject: [PATCH 03/12] 11178 fix quick search press enter button --- netbox/templates/generic/object_list.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/templates/generic/object_list.html b/netbox/templates/generic/object_list.html index 906b4ed0aa4..8b3e317c0d5 100644 --- a/netbox/templates/generic/object_list.html +++ b/netbox/templates/generic/object_list.html @@ -70,6 +70,9 @@ {% applied_filters model filter_form request.GET %} {% endif %} + {# Object table controls #} + {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %} +
{% csrf_token %} {# "Select all" form #} @@ -96,9 +99,6 @@ {% endif %} - {# Object table controls #} - {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %} -
{% csrf_token %} From f8685ad7aa276f1ccc7e15f6d2e65c2d0f1ad897 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 15 Dec 2022 10:07:55 -0800 Subject: [PATCH 04/12] 11175 fix cloning special chars in fields (#11181) * 11175 fix cloning special chars in fields * 11175 fix cloning special chars in fields --- netbox/utilities/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox/utilities/utils.py b/netbox/utilities/utils.py index a3609b47853..f635fc728aa 100644 --- a/netbox/utilities/utils.py +++ b/netbox/utilities/utils.py @@ -19,6 +19,7 @@ from extras.plugins import PluginConfig from extras.utils import is_taggable from netbox.config import get_config +from urllib.parse import urlencode from utilities.constants import HTTP_REQUEST_META_SAFE_COPY @@ -353,7 +354,7 @@ def prepare_cloned_fields(instance): params.append((key, '')) # Return a QueryDict with the parameters - return QueryDict('&'.join([f'{k}={v}' for k, v in params]), mutable=True) + return QueryDict(urlencode(params), mutable=True) def shallow_compare_dict(source_dict, destination_dict, exclude=None): From 951f82b4287356e9c05ddfe6a542bb47d4810bf6 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 15 Dec 2022 16:04:29 -0500 Subject: [PATCH 05/12] Fixes #11205: Correct cloning behavior for recursively-nested models --- docs/release-notes/version-3.4.md | 1 + netbox/netbox/models/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index bc9c49e2d53..bfa8b88b7fd 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -5,6 +5,7 @@ ### Bug Fixes * [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results +* [#11205](https://github.com/netbox-community/netbox/issues/11205) - Correct cloning behavior for recursively-nested models --- diff --git a/netbox/netbox/models/__init__.py b/netbox/netbox/models/__init__.py index d3f3e78bc2b..a4c8e0ec2f0 100644 --- a/netbox/netbox/models/__init__.py +++ b/netbox/netbox/models/__init__.py @@ -75,7 +75,7 @@ class Meta: abstract = True -class NestedGroupModel(NetBoxFeatureSet, MPTTModel): +class NestedGroupModel(CloningMixin, NetBoxFeatureSet, MPTTModel): """ Base model for objects which are used to form a hierarchy (regions, locations, etc.). These models nest recursively using MPTT. Within each parent, each child instance must have a unique name. From e4f5407c70e6c7067334a34c48f6f2fbd6dafc2a Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 15 Dec 2022 16:05:43 -0500 Subject: [PATCH 06/12] Changelog for #11175, #11178 --- 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 bfa8b88b7fd..ad307354bf1 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -4,6 +4,8 @@ ### Bug Fixes +* [#11175](https://github.com/netbox-community/netbox/issues/11175) - Fix cloning of fields containing special characters +* [#11178](https://github.com/netbox-community/netbox/issues/11178) - Pressing enter in quick search box should not trigger bulk operations * [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results * [#11205](https://github.com/netbox-community/netbox/issues/11205) - Correct cloning behavior for recursively-nested models From 9f15ca2d9005692fedbfc61992e4791eddafdd2e Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 15 Dec 2022 16:21:30 -0500 Subject: [PATCH 07/12] Closes #9971: Enable ordering of nested group models by name --- docs/release-notes/version-3.4.md | 4 ++++ netbox/netbox/tables/columns.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index ad307354bf1..7be389102b6 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -2,6 +2,10 @@ ## v3.4.1 (FUTURE) +### Enhancements + +* [#9971](https://github.com/netbox-community/netbox/issues/9971) - Enable ordering of nested group models by name + ### Bug Fixes * [#11175](https://github.com/netbox-community/netbox/issues/11175) - Fix cloning of fields containing special characters diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index 2f5c228e4cb..519f6021e8d 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -537,14 +537,15 @@ class MPTTColumn(tables.TemplateColumn): """ template_code = """ {% load helpers %} - {% for i in record.level|as_range %}{% endfor %} + {% if not table.order_by %} + {% for i in record.level|as_range %}{% endfor %} + {% endif %} {{ record.name }} """ def __init__(self, *args, **kwargs): super().__init__( template_code=self.template_code, - orderable=False, attrs={'td': {'class': 'text-nowrap'}}, *args, **kwargs From 2738da2d3985498f5ce1b4aab771f85f9edf2e85 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Dec 2022 08:43:05 -0500 Subject: [PATCH 08/12] Fixes #11189: Fix localization of dates & numbers --- docs/release-notes/version-3.4.md | 1 + netbox/netbox/settings.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 7be389102b6..8503ce8b473 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -11,6 +11,7 @@ * [#11175](https://github.com/netbox-community/netbox/issues/11175) - Fix cloning of fields containing special characters * [#11178](https://github.com/netbox-community/netbox/issues/11178) - Pressing enter in quick search box should not trigger bulk operations * [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results +* [#11189](https://github.com/netbox-community/netbox/issues/11189) - Fix localization of dates & numbers * [#11205](https://github.com/netbox-community/netbox/issues/11205) - Correct cloning behavior for recursively-nested models --- diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 8b2d4f24bcd..813d4bf0131 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -339,6 +339,7 @@ def _setting(name, default=None): 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', From ed366c5ab2bfd5d044241438f6a3283ed87b9e9d Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Dec 2022 08:56:14 -0500 Subject: [PATCH 09/12] Closes #11214: Introduce the DEFAULT_LANGUAGE configuration parameter --- docs/configuration/system.md | 11 +++++++++++ docs/release-notes/version-3.4.md | 1 + netbox/netbox/configuration_example.py | 3 +++ netbox/netbox/settings.py | 4 +--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/configuration/system.md b/docs/configuration/system.md index 3756b6a8396..5a7c8bebde5 100644 --- a/docs/configuration/system.md +++ b/docs/configuration/system.md @@ -12,6 +12,17 @@ BASE_PATH = 'netbox/' --- +## DEFAULT_LANGUAGE + +Default: `en-us` (US English) + +Defines the default preferred language/locale for requests that do not specify one. This is used to alter e.g. the display of dates and numbers to fit the user's locale. See [this list](http://www.i18nguy.com/unicode/language-identifiers.html) of standard language codes. (This parameter maps to Django's [`LANGUAGE_CODE`](https://docs.djangoproject.com/en/stable/ref/settings/#language-code) internal setting.) + +!!! note + Altering this parameter will *not* change the language used in NetBox. We hope to provide translation support in a future NetBox release. + +--- + ## DOCS_ROOT Default: `$INSTALL_ROOT/docs/` diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 8503ce8b473..32f46f1ef50 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -5,6 +5,7 @@ ### Enhancements * [#9971](https://github.com/netbox-community/netbox/issues/9971) - Enable ordering of nested group models by name +* [#11214](https://github.com/netbox-community/netbox/issues/11214) - Introduce the `DEFAULT_LANGUAGE` configuration parameter ### Bug Fixes diff --git a/netbox/netbox/configuration_example.py b/netbox/netbox/configuration_example.py index 5e057d54a11..f298b35fed5 100644 --- a/netbox/netbox/configuration_example.py +++ b/netbox/netbox/configuration_example.py @@ -106,6 +106,9 @@ # on a production system. DEBUG = False +# Set the default preferred language/locale +DEFAULT_LANGUAGE = 'en-us' + # Email settings EMAIL = { 'SERVER': 'localhost', diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 813d4bf0131..47a3c14e993 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -94,6 +94,7 @@ HTTP_PROXIES = getattr(configuration, 'HTTP_PROXIES', None) INTERNAL_IPS = getattr(configuration, 'INTERNAL_IPS', ('127.0.0.1', '::1')) JINJA2_FILTERS = getattr(configuration, 'JINJA2_FILTERS', {}) +LANGUAGE_CODE = getattr(configuration, 'DEFAULT_LANGUAGE', 'en-us') LOGGING = getattr(configuration, 'LOGGING', {}) LOGIN_PERSISTENCE = getattr(configuration, 'LOGIN_PERSISTENCE', False) LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False) @@ -386,9 +387,6 @@ def _setting(name, default=None): 'netbox.authentication.ObjectPermissionBackend', ] -# Internationalization -LANGUAGE_CODE = 'en-us' - # Time zones USE_TZ = True From c8f4a7c74266536e374d0ec74b58266842a1438b Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Fri, 16 Dec 2022 05:59:24 -0800 Subject: [PATCH 10/12] 11206 dont remove user groups if no valid REMOTE_AUTH_DEFAULT_GROUPS (#11207) * 11206 dont remove user groups if no valid REMOTE_AUTH_DEFAULT_GROUPS * 11206 dont remove user groups if no valid REMOTE_AUTH_DEFAULT_GROUPS --- netbox/netbox/authentication.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/netbox/netbox/authentication.py b/netbox/netbox/authentication.py index 89d71b8152a..798cb80e2e0 100644 --- a/netbox/netbox/authentication.py +++ b/netbox/netbox/authentication.py @@ -382,5 +382,4 @@ def user_default_groups_handler(backend, user, response, *args, **kwargs): if group_list: user.groups.add(*group_list) else: - user.groups.clear() - logger.debug(f"Stripping user {user} from Groups") + logger.info(f"No valid group assignments for {user} - REMOTE_AUTH_DEFAULT_GROUPS may be incorrectly set?") From f882dcabf792c85b18d524e27484697a44b7c944 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Dec 2022 16:45:51 -0500 Subject: [PATCH 11/12] Fixes #11184: Correct visualization of cable path which splits across multiple circuit terminations --- docs/release-notes/version-3.4.md | 1 + netbox/dcim/models/cables.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 32f46f1ef50..6648c9d5450 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -11,6 +11,7 @@ * [#11175](https://github.com/netbox-community/netbox/issues/11175) - Fix cloning of fields containing special characters * [#11178](https://github.com/netbox-community/netbox/issues/11178) - Pressing enter in quick search box should not trigger bulk operations +* [#11184](https://github.com/netbox-community/netbox/issues/11184) - Correct visualization of cable path which splits across multiple circuit terminations * [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results * [#11189](https://github.com/netbox-community/netbox/issues/11189) - Fix localization of dates & numbers * [#11205](https://github.com/netbox-community/netbox/issues/11205) - Correct cloning behavior for recursively-nested models diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index fc9d2d7a161..48c1f92db06 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -567,11 +567,12 @@ def from_origin(cls, terminations): elif isinstance(remote_terminations[0], CircuitTermination): # Follow a CircuitTermination to its corresponding CircuitTermination (A to Z or vice versa) - term_side = remote_terminations[0].term_side - assert all(ct.term_side == term_side for ct in remote_terminations[1:]) + if len(remote_terminations) > 1: + is_split = True + break circuit_termination = CircuitTermination.objects.filter( circuit=remote_terminations[0].circuit, - term_side='Z' if term_side == 'A' else 'A' + term_side='Z' if remote_terminations[0].term_side == 'A' else 'A' ).first() if circuit_termination is None: break @@ -685,6 +686,7 @@ def get_split_nodes(self): """ Return all available next segments in a split cable path. """ + from circuits.models import CircuitTermination nodes = self.path_objects[-1] # RearPort splitting to multiple FrontPorts with no stack position @@ -694,3 +696,8 @@ def get_split_nodes(self): # RearPorts connected to different cables elif type(nodes[0]) is FrontPort: return RearPort.objects.filter(pk__in=[fp.rear_port_id for fp in nodes]) + # Cable terminating to multiple CircuitTerminations + elif type(nodes[0]) is CircuitTermination: + return [ + ct.get_peer_termination() for ct in nodes + ] From 0058c7749c48a9a5f1e686fa223b5adf68b030fc Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Dec 2022 17:03:40 -0500 Subject: [PATCH 12/12] Release v3.4.1 --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yaml | 2 +- docs/release-notes/version-3.4.md | 3 ++- netbox/netbox/settings.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 09f0d5d9329..89cb0b88ebd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.4.0 + placeholder: v3.4.1 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index d94f9e9def9..ed84ff82107 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.4.0 + placeholder: v3.4.1 validations: required: true - type: dropdown diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 6648c9d5450..82d0b151c55 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -1,6 +1,6 @@ # NetBox v3.4 -## v3.4.1 (FUTURE) +## v3.4.1 (2022-12-16) ### Enhancements @@ -15,6 +15,7 @@ * [#11185](https://github.com/netbox-community/netbox/issues/11185) - Fix TemplateSyntaxError when viewing custom script results * [#11189](https://github.com/netbox-community/netbox/issues/11189) - Fix localization of dates & numbers * [#11205](https://github.com/netbox-community/netbox/issues/11205) - Correct cloning behavior for recursively-nested models +* [#11206](https://github.com/netbox-community/netbox/issues/11206) - Avoid clearing assigned groups if `REMOTE_AUTH_DEFAULT_GROUPS` is invalid --- diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 47a3c14e993..bc1b713b1e1 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -24,7 +24,7 @@ # Environment setup # -VERSION = '3.4.1-dev' +VERSION = '3.4.1' # Hostname HOSTNAME = platform.node()