mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
5fe7f4aaba
commit
ff06c722bb
8 files changed
+89
-33
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.'))
|
||||
@@ -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"""
|
||||
|
||||
Reference in new issue
Block a user