config: Add option to show advanced apps

Closes #1454.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2019-06-10 11:15:58 -07:00
1 parent 5fe7f4aaba
commit ff06c722bb
8 files changed
+89 -33

No files matched your search

+13
View File
@@ -45,6 +45,7 @@ APACHE_HOMEPAGE_CONFIG = os.path.join(APACHE_CONF_ENABLED_DIR,
APACHE_HOMEPAGE_CONF_FILE_NAME)
FREEDOMBOX_APACHE_CONFIG = os.path.join(APACHE_CONF_ENABLED_DIR,
'freedombox.conf')
ADVANCED_MODE_KEY = 'advanced_mode'
app = None
@@ -126,6 +127,18 @@ def change_home_page(shortcut_id):
actions.superuser_run('config', ['set-home-page', str(url)])
def get_advanced_mode():
"""Get whether option is enabled."""
from plinth import kvstore
return kvstore.get_default(ADVANCED_MODE_KEY, False)
def set_advanced_mode(advanced_mode):
"""Turn on/off advanced mode."""
from plinth import kvstore
kvstore.set(ADVANCED_MODE_KEY, advanced_mode)
def init():
"""Initialize the module"""
global app
+5
View File
@@ -100,3 +100,8 @@ class ConfigurationForm(forms.Form):
'/freedombox to reach {box_name} Service (Plinth).'),
box_name=ugettext_lazy(cfg.box_name)), required=False,
choices=get_homepage_choices)
advanced_mode = forms.BooleanField(
label=_('Show advanced apps and features'), required=False,
help_text=_('Show apps and features that require more technical '
'knowledge.'))
+17
View File
@@ -64,6 +64,7 @@ def get_status():
'hostname': config.get_hostname(),
'domainname': config.get_domainname(),
'homepage': config.get_home_page(),
'advanced_mode': config.get_advanced_mode(),
}
@@ -102,6 +103,22 @@ def _apply_changes(request, old_status, new_status):
else:
messages.success(request, _('Webserver home page set'))
if old_status['advanced_mode'] != new_status['advanced_mode']:
try:
config.set_advanced_mode(new_status['advanced_mode'])
except Exception as exception:
messages.error(
request,
_('Error changing advanced mode: {exception}').format(
exception=exception))
else:
if new_status['advanced_mode']:
messages.success(request,
_('Showing advanced apps and features'))
else:
messages.success(request,
_('Hiding advanced apps and features'))
def set_hostname(hostname):
"""Sets machine hostname to hostname"""