From 9e1dbdf74df7dfa4559c2e29b30ada620585fb46 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 2 May 2023 08:39:39 -0700 Subject: [PATCH 1/4] 12433 update object list widget to correctly parameterize urls --- netbox/extras/dashboard/widgets.py | 9 +++++++-- .../templates/extras/dashboard/widgets/objectlist.html | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index 9cd53763a6e..0aba01d2946 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -229,7 +229,13 @@ def render(self, request): htmx_url = reverse(viewname) except NoReverseMatch: htmx_url = None - if parameters := self.config.get('url_params'): + parameters = self.config.get('url_params') + if page_size := self.config.get('page_size'): + if not parameters: + parameters = {} + parameters['page_size'] = page_size + + if parameters: try: htmx_url = f'{htmx_url}?{urlencode(parameters, doseq=True)}' except ValueError: @@ -238,7 +244,6 @@ def render(self, request): 'viewname': viewname, 'has_permission': has_permission, 'htmx_url': htmx_url, - 'page_size': self.config.get('page_size'), }) diff --git a/netbox/templates/extras/dashboard/widgets/objectlist.html b/netbox/templates/extras/dashboard/widgets/objectlist.html index 76c4e658cdc..54f8094b326 100644 --- a/netbox/templates/extras/dashboard/widgets/objectlist.html +++ b/netbox/templates/extras/dashboard/widgets/objectlist.html @@ -1,5 +1,5 @@ {% if htmx_url and has_permission %} -
+
{% elif htmx_url %}
No permission to view this content. From 9c6ffe403730382ab26700fb39870125152f7e77 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 2 May 2023 14:53:11 -0700 Subject: [PATCH 2/4] Update netbox/extras/dashboard/widgets.py Co-authored-by: Jeremy Stretch --- netbox/extras/dashboard/widgets.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index 0aba01d2946..872cf79079a 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -229,11 +229,9 @@ def render(self, request): htmx_url = reverse(viewname) except NoReverseMatch: htmx_url = None - parameters = self.config.get('url_params') + parameters = self.config.get('url_params', {}) if page_size := self.config.get('page_size'): - if not parameters: - parameters = {} - parameters['page_size'] = page_size + parameters['page_size'] = page_size if parameters: try: From 671996a8f648c9aa69268630814552bb8ec34a32 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 2 May 2023 15:04:07 -0700 Subject: [PATCH 3/4] 12433 fix indent --- netbox/extras/dashboard/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index 872cf79079a..d22ee378247 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -231,7 +231,7 @@ def render(self, request): htmx_url = None parameters = self.config.get('url_params', {}) if page_size := self.config.get('page_size'): - parameters['page_size'] = page_size + parameters['page_size'] = page_size if parameters: try: From 8c87bae31c9daa2e7a86c4697d1f32742a77c7a5 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 3 May 2023 09:05:15 -0400 Subject: [PATCH 4/4] Correct per_page query parameter --- netbox/extras/dashboard/widgets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index d22ee378247..69d1cc36d11 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -229,9 +229,9 @@ def render(self, request): htmx_url = reverse(viewname) except NoReverseMatch: htmx_url = None - parameters = self.config.get('url_params', {}) + parameters = self.config.get('url_params') or {} if page_size := self.config.get('page_size'): - parameters['page_size'] = page_size + parameters['per_page'] = page_size if parameters: try: