From 2ed4a2b0054887daa7bc46eddc429a452c5ca422 Mon Sep 17 00:00:00 2001 From: atownson <52260120+atownson@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:02:12 -0600 Subject: [PATCH] Fixes: #18369 - Remove the json filter for protection rules (#18388) * Remove the json filter for protection rules * Configure PROTECTION_RULE config attribute to use ConfigJSONEncoder as serializer * Tweak getattr() --------- Co-authored-by: Jeremy Stretch --- netbox/core/views.py | 5 +++-- netbox/templates/core/inc/config_data.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/netbox/core/views.py b/netbox/core/views.py index 83914bcee..cd9cd6c67 100644 --- a/netbox/core/views.py +++ b/netbox/core/views.py @@ -570,8 +570,9 @@ class SystemView(UserPassesTestMixin, View): return response # Serialize any CustomValidator classes - if hasattr(config, 'CUSTOM_VALIDATORS') and config.CUSTOM_VALIDATORS: - config.CUSTOM_VALIDATORS = json.dumps(config.CUSTOM_VALIDATORS, cls=ConfigJSONEncoder, indent=4) + for attr in ['CUSTOM_VALIDATORS', 'PROTECTION_RULES']: + if hasattr(config, attr) and getattr(config, attr, None): + setattr(config, attr, json.dumps(getattr(config, attr), cls=ConfigJSONEncoder, indent=4)) return render(request, 'core/system.html', { 'stats': stats, diff --git a/netbox/templates/core/inc/config_data.html b/netbox/templates/core/inc/config_data.html index 41471a103..939b8588f 100644 --- a/netbox/templates/core/inc/config_data.html +++ b/netbox/templates/core/inc/config_data.html @@ -103,7 +103,7 @@ {% trans "Protection rules" %} {% if config.PROTECTION_RULES %} -
{{ config.PROTECTION_RULES|json }}
+
{{ config.PROTECTION_RULES }}
{% else %} {{ ''|placeholder }} {% endif %}