Filter mail addresses by domain (if any).

This commit is contained in:
Santiago Lamora 2019-12-17 11:16:23 +01:00
parent 16a59792a0
commit 9cbeb325bb

View file

@ -153,9 +153,14 @@ class MailView(ServiceListView):
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(
self.service_class.api_name)
self.service_class.api_name,
querystring=queryfilter,
)
# group addresses with the same mailbox
addresses = []
for key, group in groupby(raw_data, retrieve_mailbox):
aliases = []
@ -169,6 +174,14 @@ class MailView(ServiceListView):
return addresses
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 ''
return "domain={}".format(domain_id)
class MailingListsView(ServiceListView):
service_class = MailinglistService