mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
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 <jvalleroy@mailbox.org>
This commit is contained in:
parent
8f5dc14183
commit
6646512a0a
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user