Fix api.retrieve_mail_address_list()

This commit is contained in:
Santiago L 2021-10-05 10:04:41 +02:00
parent b0366ff1d0
commit ed5460c4b1
4 changed files with 6 additions and 27 deletions

View file

@ -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

View file

@ -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']:

View file

@ -21,11 +21,12 @@
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{% url 'musician:address-update' obj.id %}">{{ obj.mail_address }}</a></td>
<td><a href="{% url 'musician:address-update' obj.id %}">{{ obj.full_address_name }}</a></td>
<td>{{ obj.domain.name }}</td>
<td>
{% for mailbox in obj.mailboxes %}
<a href="#TODO-mailbox-detail-{{ mailbox.id }}">{{ mailbox.name }}</a>
{% if not forloop.last %}<br/> {% endif %}
{% endfor %}
</td>
<td>{{ obj.forward }}</td>

View file

@ -6,8 +6,9 @@
<a class="btn-arrow-left" href="{% url 'musician:address-list' %}">{% trans "Go to global" %}</a>
{% endif %}
<h1 class="service-name">{{ service.verbose_name }}{% if active_domain %} <span class="font-weight-light">{% trans "for"
%} {{ active_domain.name }}</span>{% endif %}</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>
{% with request.resolver_match.url_name as url_name %}