From 8ebde0dc9085431e596319e368a6667f871d3cf1 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 7 May 2019 15:19:29 -0700 Subject: [PATCH] tor: Fix issue with promoting/demoting menu item Signed-off-by: Sunil Mohan Adapa --- plinth/modules/tor/__init__.py | 24 ++++++++++++++++++++++++ plinth/modules/tor/views.py | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/plinth/modules/tor/__init__.py b/plinth/modules/tor/__init__.py index dece12353..e290e3689 100644 --- a/plinth/modules/tor/__init__.py +++ b/plinth/modules/tor/__init__.py @@ -137,6 +137,30 @@ def setup(helper, old_version=None): helper.call('post', bridge_service.notify_enabled, None, True) helper.call('post', update_hidden_service_domain) + menu = main_menu.get('apps') + helper.call('post', menu.promote_item, 'tor:index') + + +def enable(): + """Enable the app. + + XXX: Currently performs only partial activities while the rest happens + elsewhere. + + """ + menu = main_menu.get('apps') + menu.promote_item('tor:index') + + +def disable(): + """Enable the app. + + XXX: Currently performs only partial activities while the rest happens + elsewhere. + + """ + menu = main_menu.get('apps') + menu.demote_item('tor:index') def update_hidden_service_domain(status=None): diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index ce5ee532b..326b713e2 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -124,6 +124,11 @@ def __apply_changes(request, old_status, new_status): if old_status['enabled'] != new_status['enabled']: arg_value = 'enable' if new_status['enabled'] else 'disable' arguments.extend(['--service', arg_value]) + if new_status['enabled']: + tor.enable() + else: + tor.disable() + config_process = actions.superuser_run( 'tor', ['configure'] + arguments, run_in_background=True) return