mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
email: views: Implement tab rendering
This commit is contained in:
parent
8c740e08da
commit
a9ac51eb7b
13
plinth/modules/email_server/templates/email_server.html
Normal file
13
plinth/modules/email_server/templates/email_server.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{% extends "app.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block configuration %}
|
||||||
|
{{ tabs|safe }}
|
||||||
|
<p>
|
||||||
|
<a href="/rspamd/">
|
||||||
|
{% trans "Visit Rspamd administration interface" %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{{ block.super }}
|
||||||
|
{% endblock %}
|
||||||
@ -1,15 +1,56 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
import plinth
|
import io
|
||||||
|
|
||||||
|
import plinth.views
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.utils.html import escape
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from . import forms
|
from . import forms
|
||||||
|
|
||||||
|
tabs = [
|
||||||
|
('', 'Home'),
|
||||||
|
('alias', 'Alias'),
|
||||||
|
('relay', 'Relay'),
|
||||||
|
('security', 'Security')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class EmailServerView(plinth.views.AppView):
|
class EmailServerView(plinth.views.AppView):
|
||||||
"""Server configuration page"""
|
"""Server configuration page"""
|
||||||
app_id = 'email_server'
|
app_id = 'email_server'
|
||||||
form_class = forms.EmailServerForm
|
form_class = forms.EmailServerForm
|
||||||
|
template_name = 'email_server.html'
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
# old_settings = form.initial
|
# old_settings = form.initial
|
||||||
# new_status = form.cleaned_data
|
# new_status = form.cleaned_data
|
||||||
# plinth.actions.superuser_run('email_server', ['--help'])
|
# plinth.actions.superuser_run('email_server', ['--help'])
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['tabs'] = render_tabs(self.request)
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
def render_tabs(request):
|
||||||
|
sb = io.StringIO()
|
||||||
|
sb.write('<ul class="nav nav-tabs">')
|
||||||
|
for page_name, link_text in tabs:
|
||||||
|
if request.path.endswith('/' + page_name):
|
||||||
|
cls = 'active'
|
||||||
|
else:
|
||||||
|
cls = ''
|
||||||
|
if cls == 'active':
|
||||||
|
href = '#'
|
||||||
|
else:
|
||||||
|
href = escape('./' + page_name)
|
||||||
|
|
||||||
|
sb.write('<li class="nav-item">')
|
||||||
|
sb.write('<a class="nav-link {cls}" href="{href}">{text}</a>'.format(
|
||||||
|
cls=cls, href=href, text=escape(_(link_text))
|
||||||
|
))
|
||||||
|
sb.write('</li>')
|
||||||
|
sb.write('</ul>')
|
||||||
|
return sb.getvalue()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user