Merge branch 'qs_filter'
This commit is contained in:
commit
e46c006e37
|
@ -2,7 +2,7 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<a id="vert_menu" class="btn-arrow-left" href="{% url 'musician:dashboard' %}">{% trans "Go back" %}</a>
|
<a class="btn-arrow-left" href="{% url 'musician:dashboard' %}">{% trans "Go back" %}</a>
|
||||||
|
|
||||||
<h1 class="service-name">{% trans "DNS settings for" %} <span class="font-weight-light">{{ object.name }}</span></h1>
|
<h1 class="service-name">{% trans "DNS settings for" %} <span class="font-weight-light">{{ object.name }}</span></h1>
|
||||||
<p class="service-description">Litle description of what to be expected in this section to aid the user. Even a link to more help if there is one available.</p>
|
<p class="service-description">Litle description of what to be expected in this section to aid the user. Even a link to more help if there is one available.</p>
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if active_domain %}
|
||||||
|
<a class="btn-arrow-left" href="{% url 'musician:mails' %}">{% trans "Go to global" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h1 class="service-name">{{ service.verbose_name }}</h1>
|
<h1 class="service-name">{{ service.verbose_name }}{% if active_domain %} <span class="font-weight-light">{% trans "for" %} {{ active_domain.name }}</span>{% endif %}</h1>
|
||||||
<p class="service-description">{{ service.description }}</p>
|
<p class="service-description">{{ service.description }}</p>
|
||||||
<table class="table service-list">
|
<table class="table service-list">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if active_domain %}
|
||||||
|
<a class="btn-arrow-left" href="{% url 'musician:mailing-lists' %}">{% trans "Go to global" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h1 class="service-name">{{ service.verbose_name }}</h1>
|
<h1 class="service-name">{{ service.verbose_name }}{% if active_domain %} <span class="font-weight-light">{% trans "for" %} {{ active_domain.name }}</span>{% endif %}</h1>
|
||||||
<p class="service-description">{{ service.description }}</p>
|
<p class="service-description">{{ service.description }}</p>
|
||||||
|
|
||||||
<table class="table service-list">
|
<table class="table service-list">
|
||||||
|
|
|
@ -127,10 +127,17 @@ class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequ
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"ServiceListView requires a definiton of 'service'")
|
"ServiceListView requires a definiton of 'service'")
|
||||||
|
|
||||||
|
queryfilter = self.get_queryfilter()
|
||||||
json_qs = self.orchestra.retrieve_service_list(
|
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]
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context.update({
|
context.update({
|
||||||
|
@ -153,9 +160,14 @@ class MailView(ServiceListView):
|
||||||
|
|
||||||
return mailboxes[0]['id']
|
return mailboxes[0]['id']
|
||||||
|
|
||||||
# group addresses with the same mailbox
|
# retrieve mails applying filters (if any)
|
||||||
|
queryfilter = self.get_queryfilter()
|
||||||
raw_data = self.orchestra.retrieve_service_list(
|
raw_data = self.orchestra.retrieve_service_list(
|
||||||
self.service_class.api_name)
|
self.service_class.api_name,
|
||||||
|
querystring=queryfilter,
|
||||||
|
)
|
||||||
|
|
||||||
|
# group addresses with the same mailbox
|
||||||
addresses = []
|
addresses = []
|
||||||
for key, group in groupby(raw_data, retrieve_mailbox):
|
for key, group in groupby(raw_data, retrieve_mailbox):
|
||||||
aliases = []
|
aliases = []
|
||||||
|
@ -169,12 +181,49 @@ class MailView(ServiceListView):
|
||||||
|
|
||||||
return addresses
|
return addresses
|
||||||
|
|
||||||
|
def get_queryfilter(self):
|
||||||
|
"""Retrieve query params (if any) to filter queryset"""
|
||||||
|
domain_id = self.request.GET.get('domain')
|
||||||
|
if 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):
|
class MailingListsView(ServiceListView):
|
||||||
service_class = MailinglistService
|
service_class = MailinglistService
|
||||||
template_name = "musician/mailinglists.html"
|
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):
|
class DatabasesView(ServiceListView):
|
||||||
template_name = "musician/databases.html"
|
template_name = "musician/databases.html"
|
||||||
service_class = DatabaseService
|
service_class = DatabaseService
|
||||||
|
|
Loading…
Reference in New Issue