mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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 <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
94a6a9b8aa
commit
10c9156a29
@ -7,6 +7,8 @@
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
<h2>{% trans "Domains" %}</h2>
|
||||
|
||||
<form action="{{ request.path }}" method="post">
|
||||
|
||||
{% for data in fields %}
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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('<ul class="nav nav-tabs">')
|
||||
|
||||
for page_name, link_text in tab_data:
|
||||
cls = 'active' if request_path.endswith('/' + page_name) else ''
|
||||
href = '#' if cls == 'active' else ('./' + page_name)
|
||||
# -- Begin list
|
||||
sb.write('<li class="nav-item">')
|
||||
# -- Begin link
|
||||
sb.write('<a class="nav-link {}" '.format(cls))
|
||||
sb.write('href="{}">'.format(escape(href)))
|
||||
sb.write('{}</a>'.format(escape(link_text)))
|
||||
# -- End link
|
||||
sb.write('</li>')
|
||||
# -- End list
|
||||
|
||||
sb.write('</ul>')
|
||||
return sb.getvalue()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user