diff --git a/musician/templates/musician/mailinglists.html b/musician/templates/musician/mailinglists.html index e24ea7a..a5f0824 100644 --- a/musician/templates/musician/mailinglists.html +++ b/musician/templates/musician/mailinglists.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 c45517f..51a5013 100644 --- a/musician/views.py +++ b/musician/views.py @@ -127,10 +127,17 @@ class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequ raise ImproperlyConfigured( "ServiceListView requires a definiton of 'service'") + queryfilter = self.get_queryfilter() json_qs = self.orchestra.retrieve_service_list( - self.service_class.api_name) + self.service_class.api_name, + querystring=queryfilter, + ) return [self.service_class.new_from_json(data) for data in json_qs] + def get_queryfilter(self): + """Does nothing by default. Should be implemented on subclasses""" + return '' + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update({ @@ -197,6 +204,26 @@ class MailingListsView(ServiceListView): template_name = "musician/mailinglists.html" + 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 + + def get_queryfilter(self): + """Retrieve query params (if any) to filter queryset""" + # TODO(@slamora): this is not working because backend API + # doesn't support filtering by domain + domain_id = self.request.GET.get('domain') + if domain_id: + return "domain={}".format(domain_id) + + return '' + + class DatabasesView(ServiceListView): template_name = "musician/databases.html" service_class = DatabaseService