Merge remote-tracking branch 'fonfon/dev'

This commit is contained in:
Sunil Mohan Adapa 2014-09-11 19:16:13 +05:30
commit 770e4c00fd
7 changed files with 35 additions and 17 deletions

16
HACKING
View File

@ -18,23 +18,19 @@
2. Plinth also support running without installing (as much as possible).
Simply run it as:
$ sudo python -m plinth --no-daemon --debug
$ sudo ./run --no-daemon --debug
In this mode, Plinth runs in working directory without need for
installation. It uses a different config file (plinth.conf in working
directory) instead of the regular config file (/etc/plinth/plinth.conf). It
creates all that data and runtime files in data/var/*. To make Plinth
pickup the config file in working directory, simply delete
/etc/plinth/plinth.config.
installation. It uses the plinth.conf config file in the working
directory if no regular config file (/etc/plinth/plinth.conf) is found.
It creates all that data and runtime files in data/var/*.
*Note:* This mode is supported only in a limited manner. The following are
the unknown issues with it:
1. It does not work without the --debug and --no-daemon flags.
1. Help pages are also not built. Run 'make -C doc' manaully.
2. Help pages are also not built. Run 'make -C doc' manaully.
3. Actions do not work when running as normal user without 'sudo' prefix.
2. Actions do not work when running as normal user without 'sudo' prefix.
You need to add 'actions' directory to be allowed for 'sudo' commands.
See data/etc/sudoers.d/plinth for a hint.

0
bin/plinth Normal file → Executable file
View File

View File

@ -99,7 +99,8 @@ def setup_server():
# our modules to Django apps instead of reinventing the wheel.
# (we'll still have to serve the static files with cherrypy though)
for module in module_loader.LOADED_MODULES:
static_dir = os.path.join(cfg.file_root, 'modules', module, 'static')
static_dir = os.path.join(cfg.file_root, 'plinth', 'modules', module,
'static')
if not os.path.isdir(static_dir):
continue

View File

@ -136,7 +136,7 @@ def _apply_changes(request, old_status, new_status):
set_hostname(new_status['hostname'])
except Exception as exception:
messages.error(request, _('Error setting hostname: %s') %
str(exception))
exception)
else:
messages.success(request, _('Hostname set'))
else:
@ -147,7 +147,7 @@ def _apply_changes(request, old_status, new_status):
actions.superuser_run('timezone-change', [new_status['time_zone']])
except Exception as exception:
messages.error(request, _('Error setting time zone: %s') %
str(exception))
exception)
else:
messages.success(request, _('Time zone set'))
else:

View File

@ -5,7 +5,7 @@ from django.template.response import TemplateResponse
from gettext import gettext as _
from plinth import cfg
from plinth.modules.lib.auth import get_group
from plinth.modules.lib.auth import get_or_create_group
class ExpertsForm(forms.Form): # pylint: disable-msg=W0232
@ -51,7 +51,7 @@ def _apply_changes(request, new_status):
"""Apply expert mode configuration"""
message = (messages.info, _('Settings unchanged'))
expert_group = get_group('Expert')
expert_group = get_or_create_group('Expert')
if new_status['expert_mode']:
if not expert_group in request.user.groups.all():
request.user.groups.add(expert_group)

View File

@ -15,10 +15,10 @@ def add_user(username, passphrase, name='', email='', expert=False):
user.save()
if expert:
user.groups.add(get_group('Expert'))
user.groups.add(get_or_create_group('Expert'))
def get_group(name):
def get_or_create_group(name):
"""Return an existing or newly created group with given name"""
try:
group = Group.objects.get(name__exact=name)

21
run Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/python
#
# 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/>.
#
import plinth.__main__
plinth.__main__.main()