diff --git a/plinth/app.py b/plinth/app.py index 6969720f1..c093ceb32 100644 --- a/plinth/app.py +++ b/plinth/app.py @@ -42,6 +42,10 @@ class App: the app. This flag is currently set during backup and restore operations but UI changes are currently not implemented. + 'configure_when_disabled' is a boolean indicating whether the app can + configured while it is disabled. Some apps such those whose configuration + is stored in a database can't be configured while they are disabled because + the database server may not be running when the app is disabled. """ app_id: str | None = None @@ -51,6 +55,8 @@ class App: locked: bool = False # Whether user interaction with the app is allowed. # XXX: Lockdown the application UI by implementing a middleware + configure_when_disabled: bool = True + _all_apps: ClassVar[collections.OrderedDict[ str, 'App']] = collections.OrderedDict() diff --git a/plinth/tests/test_app.py b/plinth/tests/test_app.py index 86bcfec65..1ea6fc523 100644 --- a/plinth/tests/test_app.py +++ b/plinth/tests/test_app.py @@ -67,6 +67,9 @@ def test_app_instantiation(): assert app.app_id == 'test-app' assert app._all_apps['test-app'] == app assert len(app._all_apps) == 1 + assert app.can_be_disabled + assert not app.locked + assert app.configure_when_disabled def test_app_get(): diff --git a/plinth/views.py b/plinth/views.py index da37eeaea..e79c3fb5e 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -215,6 +215,11 @@ class AppView(FormView): if not self.form_class: return None + if not self.app.configure_when_disabled: + status = self.get_common_status() + if not status['is_enabled']: + return None + return super().get_form(*args, **kwargs) def _get_common_status(self):