From 10c9156a2933cb97d2b030ef09c3ae912b3113fa Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 15 Oct 2021 17:37:47 -0700 Subject: [PATCH] email_server: Remove tabs from the interface - All the views are reachable using buttons. - Add title to the domains page as tabs are removed. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- .../email_server/templates/email_domains.html | 2 ++ plinth/modules/email_server/views.py | 22 +++----------- plinth/views.py | 29 ------------------- 3 files changed, 6 insertions(+), 47 deletions(-) diff --git a/plinth/modules/email_server/templates/email_domains.html b/plinth/modules/email_server/templates/email_domains.html index 5a588b658..6bb763e5b 100644 --- a/plinth/modules/email_server/templates/email_domains.html +++ b/plinth/modules/email_server/templates/email_domains.html @@ -7,6 +7,8 @@ {{ block.super }} +

{% trans "Domains" %}

+
{% for data in fields %} diff --git a/plinth/modules/email_server/views.py b/plinth/modules/email_server/views.py index e0f54dff4..89a06a2b6 100644 --- a/plinth/modules/email_server/views.py +++ b/plinth/modules/email_server/views.py @@ -14,27 +14,13 @@ from django.views.generic.edit import FormView import plinth.actions import plinth.utils -from plinth.views import AppView, render_tabs +from plinth.views import AppView from . import aliases as aliases_module from . import audit, forms -class TabMixin(View): - admin_tabs = [('', _('Home')), ('domains', _('Domains'))] - - def get_context_data(self, *args, **kwargs): - # Retrieve context data from the next method in the MRO - context = super().get_context_data(*args, **kwargs) - # Populate context with customized data - context['tabs'] = self.render_dynamic_tabs() - return context - - def render_dynamic_tabs(self): - if plinth.utils.is_user_admin(self.request): - return render_tabs(self.request.path, self.admin_tabs) - - return '' +class ExceptionsMixin(View): def render_validation_error(self, validation_error, status=400): context = self.get_context_data() @@ -55,7 +41,7 @@ class TabMixin(View): return self.render_exception(error) -class EmailServerView(TabMixin, AppView): +class EmailServerView(ExceptionsMixin, AppView): """Server configuration page""" app_id = 'email_server' template_name = 'email_server.html' @@ -211,7 +197,7 @@ class AliasView(FormView): aliases_module.put(self._get_uid(), form.cleaned_data['alias']) -class DomainView(TabMixin, TemplateView): +class DomainView(ExceptionsMixin, TemplateView): template_name = 'email_domains.html' def get_context_data(self, *args, **kwargs): diff --git a/plinth/views.py b/plinth/views.py index 8cf07b614..c3bdbf9ba 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -3,7 +3,6 @@ Main FreedomBox views. """ -import io import time import urllib.parse @@ -12,7 +11,6 @@ from django.core.exceptions import ImproperlyConfigured from django.http import Http404, HttpResponseBadRequest, HttpResponseRedirect from django.template.response import TemplateResponse from django.urls import reverse -from django.utils.html import escape from django.utils.translation import gettext as _ from django.views.generic import TemplateView from django.views.generic.edit import FormView @@ -332,30 +330,3 @@ def notification_dismiss(request, id): notes[0].dismiss() return HttpResponseRedirect(_get_redirect_url_from_param(request)) - - -def render_tabs(request_path, tab_data): - """Generate a Bootstrap tab group and return the raw HTML - - :param request_path: value of `request.path` - :param tab_data: a list of (page_name, link_text) tuples - :returns: raw HTML of the tabs - """ - sb = io.StringIO() - sb.write('') - return sb.getvalue()