Skip to content

Commit bc688ea

Browse files
committed
[fix] Dashboard: Fixed group_by target_link
Added __exact to the target_link of group_by dashboard elements, this allows to show the filters in the target page pre-selected with the chosen value, eg: When clicking on the applied config status, not only the page shows all the devices which have their config applied but also shows the Configuration Status filter with the "applied" value already pre-selected (which was not happening before this change).
1 parent 50e7672 commit bc688ea

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

openwisp_utils/admin_theme/dashboard.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ def get_dashboard_context(request):
184184
if value.get('colors') and qs_key in value['colors']:
185185
colors.append(value['colors'][qs_key])
186186
values.append(obj['count'])
187-
value['target_link'] = f'/admin/{app_label}/{model_name}/?{group_by}='
187+
value[
188+
'target_link'
189+
] = f'/admin/{app_label}/{model_name}/?{group_by}__exact='
188190

189191
if aggregate:
190192
for qs_key, qs_value in qs.items():

tests/test_project/tests/test_dashboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def test_index_content(self):
144144
self.assertContains(response, 'Operator presence in projects')
145145
self.assertContains(response, 'with_operator')
146146
self.assertContains(response, 'without_operator')
147+
self.assertContains(response, 'project__name__exact')
147148

148149
with self.subTest('Test no data'):
149150
Project.objects.all().delete()

0 commit comments

Comments
 (0)