Split mail view into addresses & mailboxes

This commit is contained in:
Santiago L 2021-09-24 14:31:29 +02:00
parent bb07bcd126
commit 9ba1d0a23c
6 changed files with 129 additions and 46 deletions

View File

@ -0,0 +1,42 @@
{% extends "musician/mail_base.html" %}
{% load i18n %}
{% block tabcontent %}
<div class="tab-pane fade show active" id="addresses" role="tabpanel" aria-labelledby="addresses-tab">
<table class="table service-list">
<colgroup>
<col span="1" style="width: 25%;">
<col span="1" style="width: 50%;">
<col span="1" style="width: 5%;">
<col span="1" style="width: 20%;">
</colgroup>
<thead class="thead-dark">
<tr>
<th scope="col">{% trans "Mail address" %}</th>
<th scope="col">{% trans "Aliases" %}</th>
<th scope="col">{% trans "Type" %}</th>
<th scope="col">{% trans "Type details" %}</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{% url 'musician:mail-update' obj.id %}">{{ obj.mail_address }}</a></td>
<td>{{ obj.aliases|join:" , " }}</td>
<td>{{ obj.type|capfirst }}</td>
<td>
{% if obj.type == 'mailbox' %}
{% include "musician/components/usage_progress_bar.html" with detail=obj.type_detail %}
{% else %}
{{ obj.type_detail }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
{% include "musician/components/table_paginator.html" %}
</table>
<a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:mail-create' %}">{% trans "New mail address" %}</a>
</div>
{% endblock %}

View File

@ -1,45 +0,0 @@
{% extends "musician/base.html" %}
{% load i18n %}
{% 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 }}{% if active_domain %} <span class="font-weight-light">{% trans "for" %} {{ active_domain.name }}</span>{% endif %}</h1>
<p class="service-description">{{ service.description }}</p>
<table class="table service-list">
<colgroup>
<col span="1" style="width: 25%;">
<col span="1" style="width: 50%;">
<col span="1" style="width: 5%;">
<col span="1" style="width: 20%;">
</colgroup>
<thead class="thead-dark">
<tr>
<th scope="col">{% trans "Mail address" %}</th>
<th scope="col">{% trans "Aliases" %}</th>
<th scope="col">{% trans "Type" %}</th>
<th scope="col">{% trans "Type details" %}</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td><a href="{% url 'musician:mail-update' obj.id %}">{{ obj.mail_address }}</a></td>
<td>{{ obj.aliases|join:" , " }}</td>
<td>{{ obj.type|capfirst }}</td>
<td>
{% if obj.type == 'mailbox' %}
{% include "musician/components/usage_progress_bar.html" with detail=obj.type_detail %}
{% else %}
{{ obj.type_detail }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
{% include "musician/components/table_paginator.html" %}
</table>
<a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:mail-create' %}">{% trans "New mail address" %}</a>
{% endblock %}

View File

@ -0,0 +1,30 @@
{% extends "musician/base.html" %}
{% load i18n %}
{% 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 }}{% 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 %}
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link {% if url_name == 'mails' %}active{% endif %}" href="{% url 'musician:mails' %}" role="tab"
aria-selected="true">{% trans "Addresses" %}</a>
</li>
<li class="nav-item {% if url_name == 'mailboxes' %}active{% endif %}">
<a class="nav-link" href="{% url 'musician:mailboxes' %}" role="tab" aria-selected="false">{% trans "Mailboxes" %}</a>
</li>
</ul>
{% endwith %}
<div class="tab-content" id="myTabContent">
{% block tabcontent %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,34 @@
{% extends "musician/mail_base.html" %}
{% load i18n %}
{% block tabcontent %}
<div class="tab-pane fade show active" id="mailboxes" role="tabpanel" aria-labelledby="mailboxes-tab">
<table class="table service-list">
<colgroup>
<col span="1" style="width: 20%;">
<col span="1" style="width: 10%;">
<col span="1" style="width: 60%;">
<col span="1" style="width: 10%;">
</colgroup>
<thead class="thead-dark">
<tr>
<th scope="col">{% trans "Name" %}</th>
<th scope="col">{% trans "Filtering" %}</th>
<th scope="col">{% trans "Addresses" %}</th>
<th scope="col">{% trans "Active" %}</th>
</tr>
</thead>
<tbody>
{% for mailbox in mailboxes %}
<tr>
<td>{{ mailbox.name }}</td>
<td>{{ mailbox.filtering }}</td>
<td>{{ mailbox.addresses }}</td>
<td class="pl-4 text-{{ mailbox.is_active|yesno:'success,danger' }}"><i class="fas fa-{{ mailbox.is_active|yesno:'check,times' }}"></i></td>
</tr>
{% endfor %}
</tbody>
{% include "musician/components/table_paginator.html" %}
</div>
</div>
{% endblock %}

View File

@ -22,6 +22,7 @@ urlpatterns = [
path('mails/', views.MailView.as_view(), name='mails'), path('mails/', views.MailView.as_view(), name='mails'),
path('mails/new/', views.MailCreateView.as_view(), name='mail-create'), path('mails/new/', views.MailCreateView.as_view(), name='mail-create'),
path('mails/<int:pk>/', views.MailUpdateView.as_view(), name='mail-update'), path('mails/<int:pk>/', views.MailUpdateView.as_view(), name='mail-update'),
path('mailboxes/', views.MailboxesView.as_view(), name='mailboxes'),
path('mailing-lists/', views.MailingListsView.as_view(), name='mailing-lists'), path('mailing-lists/', views.MailingListsView.as_view(), name='mailing-lists'),
path('databases/', views.DatabasesView.as_view(), name='databases'), path('databases/', views.DatabasesView.as_view(), name='databases'),
path('software-as-a-service/', views.SaasView.as_view(), name='saas'), path('software-as-a-service/', views.SaasView.as_view(), name='saas'),

View File

@ -170,7 +170,7 @@ class BillDownloadView(CustomContextMixin, UserTokenRequiredMixin, View):
class MailView(ServiceListView): class MailView(ServiceListView):
service_class = Address service_class = Address
template_name = "musician/mail.html" template_name = "musician/addresses.html"
extra_context = { extra_context = {
# Translators: This message appears on the page title # Translators: This message appears on the page title
'title': _('Mail addresses'), 'title': _('Mail addresses'),
@ -199,6 +199,7 @@ class MailView(ServiceListView):
context.update({ context.update({
'active_domain': self.orchestra.retrieve_domain(domain_id) 'active_domain': self.orchestra.retrieve_domain(domain_id)
}) })
context['mailboxes'] = self.orchestra.retrieve_mailbox_list()
return context return context
@ -287,6 +288,26 @@ class MailingListsView(ServiceListView):
return '' return ''
class MailboxesView(ServiceListView):
# TODO (@slamora) refactor after encapsulating Mailbox as a service
# service_class = Mailbox
template_name = "musician/mailboxes.html"
extra_context = {
# Translators: This message appears on the page title
'title': _('Mailboxes'),
}
def get_queryset(self):
# TODO (@slamora) refactor after encapsulating Mailbox as a service
return self.orchestra.retrieve_mailbox_list()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# TODO (@slamora) refactor after encapsulating Mailbox as a service
context['mailboxes'] = context['object_list']
return context
class DatabasesView(ServiceListView): class DatabasesView(ServiceListView):
template_name = "musician/databases.html" template_name = "musician/databases.html"
service_class = DatabaseService service_class = DatabaseService