From ed5460c4b1118cae15d618b8cfc67412c6697e23 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 5 Oct 2021 10:04:41 +0200 Subject: [PATCH] Fix api.retrieve_mail_address_list() --- musician/api.py | 21 +-------------------- musician/models.py | 4 ---- musician/templates/musician/addresses.html | 3 ++- musician/templates/musician/mail_base.html | 5 +++-- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/musician/api.py b/musician/api.py index 178012e..1149eaa 100644 --- a/musician/api.py +++ b/musician/api.py @@ -131,32 +131,13 @@ class Orchestra(object): return self.request("PUT", url=url, data=data) def retrieve_mail_address_list(self, querystring=None): - def get_mailbox_id(value): - mailboxes = value.get('mailboxes') - - # forwarded address should not grouped - if len(mailboxes) == 0: - return value.get('name') - - return mailboxes[0]['id'] - # retrieve mails applying filters (if any) raw_data = self.retrieve_service_list( Address.api_name, querystring=querystring, ) - # group addresses with the same mailbox - addresses = [] - for key, group in groupby(raw_data, get_mailbox_id): - aliases = [] - data = {} - for thing in group: - aliases.append(thing.pop('name')) - data = thing - - data['names'] = aliases - addresses.append(Address.new_from_json(data)) + addresses = [Address.new_from_json(data) for data in raw_data] # PATCH to include Pangea addresses not shown by orchestra # described on issue #4 diff --git a/musician/models.py b/musician/models.py index 9e9a31e..3c86283 100644 --- a/musician/models.py +++ b/musician/models.py @@ -265,10 +265,6 @@ class Address(OrchestraModel): def full_address_name(self): return "{}@{}".format(self.name, self.domain['name']) - @property - def mail_address(self): - return self.data['names'][0] + '@' + self.data['domain']['name'] - @property def type(self): if self.data['forward']: diff --git a/musician/templates/musician/addresses.html b/musician/templates/musician/addresses.html index 4f6bf5c..8d52e06 100644 --- a/musician/templates/musician/addresses.html +++ b/musician/templates/musician/addresses.html @@ -21,11 +21,12 @@ {% for obj in object_list %} - {{ obj.mail_address }} + {{ obj.full_address_name }} {{ obj.domain.name }} {% for mailbox in obj.mailboxes %} {{ mailbox.name }} + {% if not forloop.last %}
{% endif %} {% endfor %} {{ obj.forward }} diff --git a/musician/templates/musician/mail_base.html b/musician/templates/musician/mail_base.html index 4d15891..9445f7f 100644 --- a/musician/templates/musician/mail_base.html +++ b/musician/templates/musician/mail_base.html @@ -6,8 +6,9 @@ {% trans "Go to global" %} {% endif %} -

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

+

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

{{ service.description }}

{% with request.resolver_match.url_name as url_name %}