From 05daf33ff8367439eeb57d6127bc44ee3d24b070 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 27 Nov 2019 00:17:02 -0800 Subject: [PATCH] tor: Use app.html instead of simple_app.html - Reuse status section. - Reuse configuration form. - Reuse internal zone section. - Cleanly split the page into status, internal zone and configuration blocks. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/tor/templates/tor.html | 44 +++++++++------------------ plinth/modules/tor/views.py | 17 ++++++++--- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/plinth/modules/tor/templates/tor.html b/plinth/modules/tor/templates/tor.html index bd8f16171..100a35b99 100644 --- a/plinth/modules/tor/templates/tor.html +++ b/plinth/modules/tor/templates/tor.html @@ -1,4 +1,4 @@ -{% extends "simple_app.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of FreedomBox. @@ -32,33 +32,16 @@ {% endblock %} - -{% block configuration %} - - {% include "clients.html" with clients=clients %} - -

{% trans "Status" %}

- +{% block status %} {% if config_running %} +

{% trans "Status" %}

{% trans "Tor configuration is being updated" %}

- {% else %} - -

- {% if status.is_running %} - - {% trans "Tor is running" %} - {% else %} - - {% trans "Tor is not running" %} - {% endif %} -

- - {% include "diagnostics_button.html" with module="tor" enabled=status.enabled %} + {{ block.super }} {% if status.hs_enabled %} @@ -80,19 +63,20 @@
{% endif %} + {% endif %} +{% endblock %} - {% include "internal-zone.html" %} +{% block internal_zone %} + {% if not config_running %} + {{ block.super }} + {% endif %} +{% endblock %} -

{% trans "Configuration" %}

+{% block configuration %} -
- {% csrf_token %} + {% if not config_running %} - {{ form|bootstrap }} - - -
+ {{ block.super }} {% if status.relay_enabled %}

{% trans "Relay" %}

diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index be1ecc4e4..a16668361 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -53,13 +53,18 @@ def index(request): return TemplateResponse( request, 'tor.html', { 'title': tor.name, + 'name': tor.name, 'description': tor.description, 'clients': tor.clients, 'manual_page': tor.manual_page, 'status': status, 'config_running': bool(config_process), 'form': form, - 'firewall': tor.app.get_components_of_type(Firewall) + 'firewall': tor.app.get_components_of_type(Firewall), + 'diagnostics_module_name': 'tor', + 'is_enabled': status['enabled'], + 'show_status_block': True, + 'is_running': status['is_running'], }) @@ -70,8 +75,9 @@ def _apply_changes(request, old_status, new_status): except ActionError as exception: messages.error( request, - _('Action error: {0} [{1}] [{2}]').format( - exception.args[0], exception.args[1], exception.args[2])) + _('Action error: {0} [{1}] [{2}]').format(exception.args[0], + exception.args[1], + exception.args[2])) def __apply_changes(request, old_status, new_status): @@ -131,8 +137,9 @@ def __apply_changes(request, old_status, new_status): else: tor.app.disable() - config_process = actions.superuser_run( - 'tor', ['configure'] + arguments, run_in_background=True) + config_process = actions.superuser_run('tor', + ['configure'] + arguments, + run_in_background=True) return if arguments: