From b21bc1363d2aaad9b1cc3bb0cfae5ec92c7365b6 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 29 Jan 2024 18:32:44 +0100 Subject: [PATCH] Allow filter address by domain name --- .../musician/static/musician/css/default.css | 2 +- .../templates/musician/address_list.html | 9 ++++ .../musician/components/table_paginator.html | 41 +++++-------------- orchestra/contrib/musician/views.py | 22 +++++++--- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/orchestra/contrib/musician/static/musician/css/default.css b/orchestra/contrib/musician/static/musician/css/default.css index 180c3c0d..9c6fa40f 100644 --- a/orchestra/contrib/musician/static/musician/css/default.css +++ b/orchestra/contrib/musician/static/musician/css/default.css @@ -141,7 +141,7 @@ a:hover { padding-left: 2rem; /** sidebar width **/ margin-left: 280px; - height: 100vh; + min-height: 100vh; } /** services **/ diff --git a/orchestra/contrib/musician/templates/musician/address_list.html b/orchestra/contrib/musician/templates/musician/address_list.html index 9a6714a2..50fb8633 100644 --- a/orchestra/contrib/musician/templates/musician/address_list.html +++ b/orchestra/contrib/musician/templates/musician/address_list.html @@ -2,6 +2,15 @@ {% load i18n %} {% block tabcontent %} +
+
+ +
+ + +
+ +
diff --git a/orchestra/contrib/musician/templates/musician/components/table_paginator.html b/orchestra/contrib/musician/templates/musician/components/table_paginator.html index 913d5aee..d21097b3 100644 --- a/orchestra/contrib/musician/templates/musician/components/table_paginator.html +++ b/orchestra/contrib/musician/templates/musician/components/table_paginator.html @@ -1,38 +1,18 @@ {# #} -{% load i18n %} +{% load i18n bootstrap4 %} - - - + {% comment %} + + + + {% endcomment %} diff --git a/orchestra/contrib/musician/views.py b/orchestra/contrib/musician/views.py index 1a5667ab..b7f0d3fa 100644 --- a/orchestra/contrib/musician/views.py +++ b/orchestra/contrib/musician/views.py @@ -237,15 +237,22 @@ class AddressListView(ServiceListView): def get_queryfilter(self): """Retrieve query params (if any) to filter queryset""" - domain_id = self.request.GET.get('domain') - if domain_id: - return {"domain": domain_id} + queryfilter = {} - return {} + domain_id = self.clean_domain_id() + if domain_id: + queryfilter.update({"domain": domain_id}) + + else: + domain_name = self.request.GET.get('domain__name') + if domain_name: + queryfilter.update({"domain__name__icontains": domain_name}) + + return queryfilter def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - domain_id = self.request.GET.get('domain') + domain_id = self.clean_domain_id() if domain_id: qs = Domain.objects.filter(account=self.request.user) context.update({ @@ -254,6 +261,11 @@ class AddressListView(ServiceListView): context['mailboxes'] = Mailbox.objects.filter(account=self.request.user) return context + def clean_domain_id(self): + try: + return int(self.request.GET.get('domain', '')) + except ValueError: + return None class MailCreateView(CustomContextMixin, UserTokenRequiredMixin, CreateView): service_class = AddressService
{{ page_obj.paginator.count }} items in total - + +
+ {% bootstrap_pagination page_obj extra="per_page" %} +
+
Showing