From 6646512a0adab6943503ec47372502fb28805911 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 7 Mar 2024 18:04:29 -0800 Subject: [PATCH] zoph: Don't redirect to setup page when app is disabled - When app is disabled, it can't be setup as it requires database server and connecting to the database. - If app is disabled, we don't show configuration any more, so redirection to setup page is also not needed. This results in neither setup nor configuration being shown when app is disabled. - During uninstall process, app is disable for first. So, the workaround implemented in is_configured() is no longer needed. Tests: - Install zoph. Setup page is shown. Disable the app by disabling the apache configuration for it and restart service. Setup is no longer shown. - Uninstall zoph. During the uninstall setup, when page is refreshing, setup page is not shown. Reviewed-by: James Valleroy --- plinth/modules/zoph/privileged.py | 10 +++------- plinth/modules/zoph/views.py | 10 +++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/plinth/modules/zoph/privileged.py b/plinth/modules/zoph/privileged.py index 67e386a48..fe3decdcf 100644 --- a/plinth/modules/zoph/privileged.py +++ b/plinth/modules/zoph/privileged.py @@ -95,13 +95,9 @@ def set_configuration(enable_osm: bool | None = None, @privileged def is_configured() -> bool | None: """Return whether zoph app is configured.""" - try: - process = subprocess.run( - ['zoph', '--get-config', 'interface.user.remote'], - stdout=subprocess.PIPE, check=True) - return process.stdout.decode().strip() == 'true' - except FileNotFoundError: - return None + process = subprocess.run(['zoph', '--get-config', 'interface.user.remote'], + stdout=subprocess.PIPE, check=True) + return process.stdout.decode().strip() == 'true' @privileged diff --git a/plinth/modules/zoph/views.py b/plinth/modules/zoph/views.py index f646f5de6..9e9cabb1b 100644 --- a/plinth/modules/zoph/views.py +++ b/plinth/modules/zoph/views.py @@ -48,12 +48,12 @@ class ZophAppView(views.AppView): def dispatch(self, request, *args, **kwargs): """Redirect to setup page if setup is not done yet.""" - is_configured = privileged.is_configured() - if is_configured is False: - return redirect('zoph:setup') + status = self.get_common_status() + if status['is_enabled']: + # When disabled, such as when uninstalling + if privileged.is_configured() is False: + return redirect('zoph:setup') - # During operations such as uninstall, zoph command may not be - # available, let the base class show operations view instead. return super().dispatch(request, *args, **kwargs) def get_initial(self):