From bca9d0fa8ae243459191355edaf625748b1fde42 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 30 May 2023 16:31:34 -0400 Subject: [PATCH] Closes #12599: Apply filter parameters to links in object count dashboard widgets --- docs/release-notes/version-3.5.md | 1 + netbox/extras/dashboard/widgets.py | 5 +++-- netbox/templates/extras/dashboard/widgets/objectcounts.html | 6 ++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/release-notes/version-3.5.md b/docs/release-notes/version-3.5.md index 6656aa1bb..ac02f0f79 100644 --- a/docs/release-notes/version-3.5.md +++ b/docs/release-notes/version-3.5.md @@ -7,6 +7,7 @@ * [#12470](https://github.com/netbox-community/netbox/issues/12470) - Collapse context data by default when viewing a rendered device configuration * [#12562](https://github.com/netbox-community/netbox/issues/12562) - Record client IP address when logging authentication failures * [#12597](https://github.com/netbox-community/netbox/issues/12597) - Add an option to hide custom fields only if unset +* [#12599](https://github.com/netbox-community/netbox/issues/12599) - Apply filter parameters to links in object count dashboard widgets ### Bug Fixes diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index ed50a8451..b3a4d090c 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -174,10 +174,11 @@ class ObjectCountsWidget(DashboardWidget): params.update(filters) filterset = getattr(resolve(url).func.view_class, 'filterset', None) qs = filterset(params, qs).qs + url = f'{url}?{params.urlencode()}' object_count = qs.count - counts.append((model, object_count)) + counts.append((model, object_count, url)) else: - counts.append((model, None)) + counts.append((model, None, None)) return render_to_string(self.template_name, { 'counts': counts, diff --git a/netbox/templates/extras/dashboard/widgets/objectcounts.html b/netbox/templates/extras/dashboard/widgets/objectcounts.html index d0e604c9a..8b68dc166 100644 --- a/netbox/templates/extras/dashboard/widgets/objectcounts.html +++ b/netbox/templates/extras/dashboard/widgets/objectcounts.html @@ -1,10 +1,8 @@ -{% load helpers %} - {% if counts %}
- {% for model, count in counts %} + {% for model, count, url in counts %} {% if count != None %} - +
{{ model|meta:"verbose_name_plural"|bettertitle }}
{{ count }}