From 5520ff63f307dfe2b177592629c8a38c454dc93b Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 17 Dec 2019 11:32:38 +0100 Subject: [PATCH] Show active_domain and add 'go to global' button. --- musician/templates/musician/mail.html | 5 ++++- musician/views.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/musician/templates/musician/mail.html b/musician/templates/musician/mail.html index f247653..e8ae8be 100644 --- a/musician/templates/musician/mail.html +++ b/musician/templates/musician/mail.html @@ -2,8 +2,11 @@ {% load i18n %} {% block content %} +{% if active_domain %} +{% trans "Go to global" %} +{% endif %} -

{{ service.verbose_name }}

+

{{ service.verbose_name }}{% if active_domain %} {% trans "for" %} {{ active_domain.name }}{% endif %}

{{ service.description }}

diff --git a/musician/views.py b/musician/views.py index 7ad9187..c45517f 100644 --- a/musician/views.py +++ b/musician/views.py @@ -177,10 +177,19 @@ class MailView(ServiceListView): def get_queryfilter(self): """Retrieve query params (if any) to filter queryset""" domain_id = self.request.GET.get('domain') - if domain_id is None: - return '' + if domain_id: + return "domain={}".format(domain_id) - return "domain={}".format(domain_id) + return '' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + domain_id = self.request.GET.get('domain') + if domain_id: + context.update({ + 'active_domain': self.orchestra.retrieve_domain(domain_id) + }) + return context class MailingListsView(ServiceListView):