mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Move all modules from 'modules/installed' to 'modules' directory
This commit is contained in:
1 parent
912c5022ca
commit
37206f1e83
72 files changed
+20
-22
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for expert mode configuration
|
||||
"""
|
||||
|
||||
from . import expert_mode
|
||||
|
||||
|
||||
__all__ = ['expert_mode']
|
||||
@@ -0,0 +1,79 @@
|
||||
import cherrypy
|
||||
from django import forms
|
||||
from gettext import gettext as _
|
||||
from ..lib.auth import require
|
||||
from plugin_mount import PagePlugin
|
||||
import cfg
|
||||
import util
|
||||
|
||||
|
||||
class ExpertsForm(forms.Form): # pylint: disable-msg=W0232
|
||||
"""Form to configure expert mode"""
|
||||
|
||||
expert_mode = forms.BooleanField(
|
||||
label=_('Expert Mode'), required=False)
|
||||
|
||||
# XXX: Only present due to issue with submitting empty form
|
||||
dummy = forms.CharField(label='Dummy', initial='dummy',
|
||||
widget=forms.HiddenInput())
|
||||
|
||||
|
||||
class Experts(PagePlugin):
|
||||
"""Expert forms page"""
|
||||
order = 60
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
PagePlugin.__init__(self, *args, **kwargs)
|
||||
self.register_page('sys.expert')
|
||||
|
||||
cfg.html_root.sys.menu.add_item(_('Expert Mode'), 'icon-cog',
|
||||
'/sys/expert', 10)
|
||||
|
||||
@cherrypy.expose
|
||||
@require()
|
||||
def index(self, **kwargs):
|
||||
"""Serve the configuration form"""
|
||||
status = self.get_status()
|
||||
|
||||
cfg.log.info('Args - %s' % kwargs)
|
||||
|
||||
form = None
|
||||
messages = []
|
||||
|
||||
if kwargs:
|
||||
form = ExpertsForm(kwargs, prefix='experts')
|
||||
# pylint: disable-msg=E1101
|
||||
if form.is_valid():
|
||||
self._apply_changes(form.cleaned_data, messages)
|
||||
status = self.get_status()
|
||||
form = ExpertsForm(initial=status, prefix='experts')
|
||||
else:
|
||||
form = ExpertsForm(initial=status, prefix='experts')
|
||||
|
||||
return util.render_template(template='expert_mode',
|
||||
title=_('Expert Mode'), form=form,
|
||||
messages=messages)
|
||||
|
||||
@staticmethod
|
||||
def get_status():
|
||||
"""Return the current status"""
|
||||
return {'expert_mode': cfg.users.expert()}
|
||||
|
||||
@staticmethod
|
||||
def _apply_changes(new_status, messages):
|
||||
"""Apply expert mode configuration"""
|
||||
message = ('info', _('Settings unchanged'))
|
||||
|
||||
user = cfg.users.current()
|
||||
|
||||
if new_status['expert_mode']:
|
||||
if not 'expert' in user['groups']:
|
||||
user['groups'].append('expert')
|
||||
message = ('success', _('Expert mode enabled'))
|
||||
else:
|
||||
if 'expert' in user['groups']:
|
||||
user['groups'].remove('expert')
|
||||
message = ('success', _('Expert mode disabled'))
|
||||
|
||||
cfg.users.set(user['username'], user)
|
||||
messages.append(message)
|
||||
@@ -0,0 +1,51 @@
|
||||
{% extends "login_nav.html" %}
|
||||
{% comment %}
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
|
||||
{% block main_block %}
|
||||
|
||||
{% include 'messages.html' %}
|
||||
|
||||
<p>The {{ cfg.box_name }} can be administered in two modes, 'basic'
|
||||
and 'expert'. Basic mode hides a lot of features and configuration
|
||||
options that most users will never need to think about. Expert mode
|
||||
allows you to get into the details.</p>
|
||||
|
||||
<p>Most users can operate the {{ cfg.box_name }} by configuring the
|
||||
limited number of options visible in Basic mode. For the sake of
|
||||
simplicity and ease of use, we hid most of {{ cfg.product_name }}'s
|
||||
less frequently used options. But if you want more sophisticated
|
||||
features, you can enable Expert mode, and {{ cfg.product_name }}
|
||||
will present more advanced menu options.</p>
|
||||
|
||||
<p>You should be aware that it might be possible to render your
|
||||
{{ cfg.box_name }} inaccessible via Expert mode options.</p>
|
||||
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn-primary" value="Submit"/>
|
||||
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user