From 8a8c29382ae5464c321244eb82e2ab11c7fa27f3 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 16 Sep 2020 14:57:06 +0200 Subject: [PATCH] personal: Make group filter more usable - Put "reset filter" on top of list - If a group is selected, show the name instead of "Filter by group" --- mpicms/personal/views.py | 4 ++++ mpicms/templates/personal/list.html | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mpicms/personal/views.py b/mpicms/personal/views.py index bcc49c6..207d043 100644 --- a/mpicms/personal/views.py +++ b/mpicms/personal/views.py @@ -1,4 +1,5 @@ from django.views.generic.list import ListView +from django.shortcuts import get_object_or_404 from .models import Contact, Group @@ -16,6 +17,9 @@ def get_queryset(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['groups'] = Group.objects.all() + group_pk = self.request.GET.get('group') + context['selected_group_pk'] = group_pk + context['selected_group'] = get_object_or_404(Group, pk=group_pk) if group_pk else "" return context diff --git a/mpicms/templates/personal/list.html b/mpicms/templates/personal/list.html index e410f01..e882a2b 100644 --- a/mpicms/templates/personal/list.html +++ b/mpicms/templates/personal/list.html @@ -8,25 +8,24 @@

{% trans 'Contact List' %}