apps, system: Remove modules and merge into main

- Remove apps and system modules and merge their views into main views.

- Move main_menu from cfg into menu.py.

- Remove dependencies of other modules on apps and system modules.

- Update tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2017-04-06 17:17:28 +05:30 committed by James Valleroy
parent 184bced823
commit ee7cc98fee
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
64 changed files with 164 additions and 354 deletions

View File

@ -1 +0,0 @@
plinth.modules.apps

View File

@ -1 +0,0 @@
plinth.modules.system

View File

@ -30,6 +30,7 @@ import sys
import cherrypy
from plinth import cfg
from plinth import menu
from plinth import module_loader
from plinth import service
from plinth import setup
@ -330,6 +331,8 @@ def main():
module_loader.include_urls()
menu.init()
module_loader.load_modules()
if arguments.setup is not False:
run_setup_and_exit(arguments.setup)

View File

@ -19,8 +19,6 @@ import configparser
import logging
import os
from plinth.menu import Menu
logger = logging.getLogger(__name__)
box_name = None
@ -41,8 +39,6 @@ debug = False
server_dir = '/'
danube_edition = False
main_menu = Menu()
config_file = None
DEFAULT_CONFIG_FILE = '/etc/plinth/plinth.config'

View File

@ -23,6 +23,7 @@ from django.utils.translation import ugettext as _, ugettext_noop
import re
from plinth import cfg
from plinth.menu import main_menu
from plinth.utils import is_user_admin
@ -40,7 +41,7 @@ def common(request):
active_menu_urls = [request.path[:index + 1] for index in slash_indices]
return {
'cfg': cfg,
'submenu': cfg.main_menu.active_item(request),
'submenu': main_menu.active_item(request),
'active_menu_urls': active_menu_urls,
'box_name': _(cfg.box_name),
'user_is_admin': is_user_admin(request, True)

View File

@ -84,3 +84,12 @@ class Menu(object):
for item in self.items:
if request.path.startswith(str(item.url)):
return item
main_menu = Menu()
def init():
"""Create main menu and other essential menus."""
main_menu.add_urlname('', 'glyphicon-download-alt', 'apps')
main_menu.add_urlname('', 'glyphicon-cog', 'system')

View File

@ -1,29 +0,0 @@
#
# 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 Apps section page
"""
from . import apps
from .apps import init
__all__ = ['apps', 'init']
version = 1
is_essential = True

View File

@ -1,32 +0,0 @@
#
# 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/>.
#
from django.template.response import TemplateResponse
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
def init():
"""Initailize the apps module"""
cfg.main_menu.add_urlname(_('Apps'), 'glyphicon-download-alt',
'apps:index')
def index(request):
"""Serve the apps index page"""
return TemplateResponse(request, 'apps.html', {'title': _('Applications')})

View File

@ -1,29 +0,0 @@
#
# 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/>.
#
"""
URLs for the Apps module
"""
from django.conf.urls import url
from . import apps as views
urlpatterns = [
url(r'^apps/$', views.index, name='index'),
]

View File

@ -23,6 +23,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
from plinth.views import ServiceView
@ -32,8 +33,6 @@ version = 1
is_essential = True
depends = ['system']
managed_services = ['avahi-daemon']
managed_packages = ['avahi-daemon']
@ -56,7 +55,7 @@ service = None
def init():
"""Intialize the service discovery module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-lamp', 'avahi:index')
global service # pylint: disable=W0603

View File

@ -25,14 +25,12 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['system']
title = _('Domain Name Server \n (BIND)')
service = None
@ -57,7 +55,7 @@ CONFIG_FILE = '/etc/bind/named.conf.options'
def init():
"""Intialize the BIND module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-globe', 'bind:index')
global service

View File

@ -28,4 +28,4 @@ version = 1
is_essential = True
depends = ['system', 'firewall', 'names']
depends = ['firewall', 'names']

View File

@ -35,6 +35,7 @@ import socket
import plinth
from plinth import actions
from plinth import cfg
from plinth.menu import main_menu
from plinth.modules import firewall
from plinth.modules.names import SERVICES
from plinth.signals import pre_hostname_change, post_hostname_change
@ -146,7 +147,7 @@ class ConfigurationForm(forms.Form):
def init():
"""Initialize the module"""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(ugettext_lazy('Configure'), 'glyphicon-cog',
'config:index')

View File

@ -22,16 +22,14 @@ Plinth module to configure system date and time
from django.utils.translation import ugettext_lazy as _
import subprocess
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
managed_services = ['ntp']
managed_packages = ['ntp']
@ -48,7 +46,7 @@ service = None
def init():
"""Intialize the date/time module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-time', 'datetime:index')
global service

View File

@ -23,15 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
service = None
managed_services = ['deluge-web']
@ -53,7 +51,7 @@ reserved_usernames = ['debian-deluged']
def init():
"""Initialize the Deluge module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-magnet', 'deluge:index')
global service

View File

@ -22,7 +22,8 @@ Plinth module for system diagnostics
from django.utils.translation import ugettext_lazy as _
from plinth import action_utils
from plinth import cfg
from plinth.menu import main_menu
version = 1
@ -36,12 +37,10 @@ description = [
'expected.')
]
depends = ['system']
def init():
"""Initialize the module"""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-screenshot', 'diagnostics:index')

View File

@ -20,18 +20,15 @@ Plinth module to manage disks.
"""
from django.utils.translation import ugettext_lazy as _
import json
import logging
import subprocess
from plinth import actions
from plinth import cfg
from plinth.menu import main_menu
version = 1
depends = ['system']
title = _('Disks')
description = []
@ -43,7 +40,7 @@ logger = logging.getLogger(__name__)
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-hdd', 'disks:index')

View File

@ -22,11 +22,11 @@ Plinth module to configure ez-ipupdate client
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['system']
version = 1
managed_packages = ['ez-ipupdate']
@ -54,7 +54,7 @@ reserved_usernames = ['ez-ipupd']
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-refresh', 'dynamicdns:index')

View File

@ -26,17 +26,15 @@ import socket
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.signals import pre_hostname_change, post_hostname_change
from plinth.signals import domainname_change
version = 1
depends = ['apps']
managed_services = ['ejabberd']
managed_packages = ['ejabberd']
@ -61,7 +59,7 @@ logger = logging.getLogger(__name__)
def init():
"""Initialize the ejabberd module"""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-comment', 'ejabberd:index')
global service

View File

@ -24,16 +24,16 @@ import logging
from plinth import actions
from plinth import cfg
from plinth.menu import main_menu
from plinth.signals import service_enabled
import plinth.service as service_module
from plinth.utils import format_lazy
version = 1
is_essential = True
depends = ['system']
managed_packages = ['firewalld']
title = _('Firewall')
@ -51,7 +51,7 @@ LOGGER = logging.getLogger(__name__)
def init():
"""Initailze firewall module"""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-fire', 'firewall:index')
service_enabled.connect(on_service_enabled)

View File

@ -37,7 +37,7 @@
</p>
<div class="text-center">
<a class="btn btn-lg btn-primary" href="{% url 'apps:index' %}">
<a class="btn btn-lg btn-primary" href="{% url 'apps' %}">
{% trans "Go to Apps" %}</a>
</div>

View File

@ -27,12 +27,13 @@ from django.utils.translation import ugettext as _, ugettext_lazy
from stronghold.decorators import public
from plinth import cfg, __version__
from plinth.menu import main_menu
def init():
"""Initialize the Help module"""
menu = cfg.main_menu.add_urlname(ugettext_lazy('Documentation'),
'glyphicon-book', 'help:index')
menu = main_menu.add_urlname(ugettext_lazy('Documentation'),
'glyphicon-book', 'help:index')
menu.add_urlname(ugettext_lazy('Where to Get Help'), 'glyphicon-search',
'help:index_explicit', 5)
menu.add_urlname(ugettext_lazy('Manual'), 'glyphicon-info-sign',

View File

@ -23,15 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_packages = ['ikiwiki', 'libdigest-sha-perl', 'libxml-writer-perl',
'xapian-omega', 'libsearch-xapian-perl',
'libimage-magick-perl']
@ -51,7 +49,7 @@ description = [
def init():
"""Initialize the ikiwiki module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-edit', 'ikiwiki:index')
global service

View File

@ -27,14 +27,13 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
from plinth.views import ServiceView
version = 1
depends = ['apps']
service = None
managed_services = ['infinoted']
@ -56,7 +55,7 @@ description = [
def init():
"""Initialize the infinoted module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-pencil', 'infinoted:index')
global service

View File

@ -24,15 +24,13 @@ from django.utils.translation import ugettext_lazy as _
import logging
import socket
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_packages = ['libjs-jsxc']
title = _('Chat Client \n (JSXC)')
@ -50,7 +48,7 @@ logger = logging.getLogger(__name__)
def init():
"""Initialize the JSXC module"""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-comment', 'jsxc:index')
global service

View File

@ -23,6 +23,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import action_utils
from plinth import cfg
from plinth.menu import main_menu
from plinth.modules import names
from plinth.utils import format_lazy
@ -31,7 +32,7 @@ version = 1
is_essential = False
depends = ['apps', 'names']
depends = ['names']
managed_packages = ['certbot']
@ -59,7 +60,7 @@ service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(_('Certificates (Let\'s Encrypt)'),
'glyphicon-lock', 'letsencrypt:index')

View File

@ -28,14 +28,13 @@ from ruamel.yaml.util import load_yaml_guess_indent
from plinth import action_utils
from plinth import actions
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.modules import names
version = 1
depends = ['apps']
version = 1
managed_services = ['matrix-synapse']
@ -67,7 +66,7 @@ SERVER_NAME_PATH = "/etc/matrix-synapse/conf.d/server_name.yaml"
def init():
"""Initialize the matrix-synapse module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-comment', 'matrixsynapse:index')
global service

View File

@ -29,13 +29,12 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 2
depends = ['apps']
service = None
managed_services = ['minetest-server']
@ -65,7 +64,7 @@ AUG_PATH = '/files' + CONFIG_FILE + '/.anon'
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-th-large', 'minetest:index')
global service

View File

@ -21,12 +21,11 @@ Plinth module for monkeysphere.
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth.menu import main_menu
version = 1
depends = ['system']
managed_packages = ['monkeysphere']
title = _('Monkeysphere')
@ -56,7 +55,7 @@ reserved_usernames = ['monkeysphere']
def init():
"""Initialize the monkeysphere module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(_('Monkeysphere'), 'glyphicon-certificate',
'monkeysphere:index')

View File

@ -24,16 +24,14 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.views import ServiceView
version = 1
depends = ['apps']
title = _('Voice Chat \n (Mumble)')
service = None
@ -56,7 +54,7 @@ reserved_usernames = ['mumble-server']
def init():
"""Intialize the Mumble module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-headphones', 'mumble:index')
global service

View File

@ -22,9 +22,10 @@ Plinth module to configure name services
from django.utils.translation import ugettext_lazy as _
import logging
from plinth import cfg
from plinth.menu import main_menu
from plinth.signals import domain_added, domain_removed
SERVICES = (
('http', _('HTTP'), 80),
('https', _('HTTPS'), 443),
@ -35,8 +36,6 @@ version = 1
is_essential = True
depends = ['system']
title = _('Name Services')
domain_types = {}
@ -47,7 +46,7 @@ logger = logging.getLogger(__name__)
def init():
"""Initialize the names module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-tag', 'names:index')
domain_added.connect(on_domain_added)

View File

@ -24,16 +24,14 @@ from logging import Logger
import subprocess
from plinth import action_utils
from plinth import cfg
from plinth import network
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
managed_packages = ['network-manager', 'batctl']
title = _('Networks')
@ -43,7 +41,7 @@ logger = Logger(__name__)
def init():
"""Initialize the Networks module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-signal', 'networks:index')

View File

@ -27,13 +27,12 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['apps']
service = None
managed_services = ['openvpn@freedombox']
@ -56,8 +55,7 @@ description = [
def init():
"""Initialize the OpenVPN module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-lock', 'openvpn:index')
global service

View File

@ -23,11 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from . import utils
from plinth import cfg
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['system', 'names']
depends = ['names']
managed_packages = ['pagekite']
@ -77,7 +79,7 @@ description = [
def init():
"""Intialize the PageKite module"""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-flag', 'pagekite:index')
# Register kite name with Name Services module.

View File

@ -21,14 +21,12 @@ Plinth module for power controls.
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
title = _('Power')
description = [
@ -38,5 +36,5 @@ description = [
def init():
"""Initialize the power module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-off', 'power:index')

View File

@ -42,7 +42,7 @@ def restart(request):
if request.method == 'POST':
actions.superuser_run('power', ['restart'], async=True)
return redirect(reverse('apps:index'))
return redirect(reverse('apps'))
else:
form = Form(prefix='power')
@ -57,7 +57,7 @@ def shutdown(request):
if request.method == 'POST':
actions.superuser_run('power', ['shutdown'], async=True)
return redirect(reverse('apps:index'))
return redirect(reverse('apps'))
else:
form = Form(prefix='power')

View File

@ -27,6 +27,7 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
from plinth.views import ServiceView
@ -35,8 +36,6 @@ version = 1
is_essential = False
depends = ['apps']
managed_services = ['privoxy']
managed_packages = ['privoxy']
@ -66,7 +65,7 @@ service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-cloud-upload', 'privoxy:index')
global service

View File

@ -27,13 +27,12 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
from plinth.views import ServiceView
version = 1
depends = ['apps']
service = None
managed_services = ['quasselcore']
@ -64,7 +63,7 @@ reserved_usernames = ['quasselcore']
def init():
"""Initialize the quassel module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-retweet', 'quassel:index')
global service

View File

@ -28,11 +28,11 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['apps']
version = 1
service = None
@ -59,7 +59,7 @@ CONFIG_FILE = '/etc/radicale/config'
def init():
"""Initialize the radicale module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-calendar', 'radicale:index')
global service

View File

@ -24,15 +24,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.views import ServiceView
version = 2
depends = ['apps']
managed_services = ['repro']
managed_packages = ['repro']
@ -67,7 +65,7 @@ service = None
def init():
"""Initialize the repro module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-phone-alt', 'repro:index')
global service

View File

@ -23,13 +23,12 @@ from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['apps']
managed_services = ['node-restore']
managed_packages = ['node-restore']
@ -56,7 +55,7 @@ service = None
def init():
"""Initialize the reStore module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-hdd', 'restore:index')
global service

View File

@ -23,15 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_packages = ['sqlite3', 'roundcube', 'roundcube-sqlite3']
title = _('Email Client \n (Roundcube)')
@ -63,7 +61,7 @@ service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-envelope', 'roundcube:index')
global service

View File

@ -21,16 +21,14 @@ Plinth module for security configuration
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth import actions
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
title = _('Security')
@ -40,7 +38,7 @@ ACCESS_CONF_SNIPPET = '-:ALL EXCEPT root fbx (admin) (sudo):ALL'
def init():
"""Initialize the module"""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-lock', 'security:index')

View File

@ -23,15 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_packages = ['shaarli']
title = _('Bookmarks \n (Shaarli)')
@ -50,7 +48,7 @@ service = None
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-bookmark', 'shaarli:index')
global service

View File

@ -22,13 +22,11 @@ Plinth module to manage filesystem snapshots.
from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import cfg
from plinth.menu import main_menu
version = 1
depends = ['system']
managed_packages = ['snapper']
title = _('Snapshots')
@ -52,7 +50,7 @@ service = None
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-film', 'snapshot:index')

View File

@ -26,13 +26,12 @@ from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.utils import format_lazy
version = 1
depends = ['apps']
managed_services = ['syncthing']
managed_packages = ['syncthing']
@ -62,7 +61,7 @@ service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-refresh', 'syncthing:index')
global service

View File

@ -1,47 +0,0 @@
#
# 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 system section page
"""
from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth.utils import format_lazy
version = 1
is_essential = True
title = _('System Configuration')
description = [
format_lazy(
_('Here you can administrate the underlying system of your '
'{box_name}.'), box_name=_(cfg.box_name)),
format_lazy(
_('The options affect the {box_name} at its most general level, '
'so be careful!'), box_name=_(cfg.box_name))
]
def init():
"""Initialize the system module"""
cfg.main_menu.add_urlname(title, 'glyphicon-cog', 'system:index')

View File

@ -1,29 +0,0 @@
#
# 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/>.
#
"""
URLs for the System module
"""
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/$', views.index, name='index'),
]

View File

@ -1,27 +0,0 @@
#
# 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/>.
#
from django.template.response import TemplateResponse
from plinth.modules import system
def index(request):
"""Serve the index page"""
return TemplateResponse(request, 'system.html',
{'title': system.title,
'description': system.description})

View File

@ -24,8 +24,8 @@ import json
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.modules.names import SERVICES
from plinth.signals import domain_added, domain_removed
@ -34,7 +34,7 @@ from . import utils
version = 2
depends = ['apps', 'names']
depends = ['names']
managed_packages = ['tor', 'tor-geoipdb', 'torsocks', 'obfs4proxy',
'apt-transport-tor']
@ -58,7 +58,7 @@ bridge_service = None
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-eye-close', 'tor:index')
setup_helper = globals()['setup_helper']

View File

@ -24,15 +24,13 @@ import json
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_services = ['transmission-daemon']
managed_packages = ['transmission-daemon']
@ -53,7 +51,7 @@ service = None
def init():
"""Intialize the Transmission module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-save', 'transmission:index')
global service

View File

@ -23,15 +23,13 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import frontpage
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
depends = ['apps']
managed_services = ['tt-rss']
managed_packages = ['tt-rss', 'postgresql', 'dbconfig-pgsql', 'php-pgsql']
@ -52,7 +50,7 @@ service = None
def init():
"""Intialize the module."""
menu = cfg.main_menu.get('apps:index')
menu = main_menu.get('apps')
menu.add_urlname(title, 'glyphicon-envelope', 'ttrss:index')
global service

View File

@ -22,16 +22,14 @@ Plinth module for upgrades
from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import cfg
from plinth import service as service_module
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
managed_packages = ['unattended-upgrades']
title = _('Software Upgrades')
@ -47,7 +45,7 @@ service = None
def init():
"""Initialize the module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-refresh', 'upgrades:index')
global service
service = service_module.Service(

View File

@ -22,16 +22,15 @@ Plinth module to manage users
from django.utils.translation import ugettext_lazy as _
import subprocess
from plinth import cfg
from plinth import action_utils
from plinth import actions
from plinth.menu import main_menu
version = 1
is_essential = True
depends = ['system']
managed_packages = ['ldapscripts', 'ldap-utils', 'libnss-ldapd',
'libpam-ldapd', 'nslcd', 'slapd']
@ -48,7 +47,7 @@ title = _('Users and Groups')
def init():
"""Intialize the user module."""
menu = cfg.main_menu.get('system:index')
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-user', 'users:index')

View File

@ -103,13 +103,13 @@
</a>
</li>
<li>
<a href="{% url 'apps:index' %}" title="{% trans "Apps" %}">
<a href="{% url 'apps' %}" title="{% trans "Apps" %}">
<span class="glyphicon glyphicon-th"></span>
{% trans "Apps" %}
</a>
</li>
<li>
<a href="{% url 'system:index' %}" title="{% trans "Configuration" %}">
<a href="{% url 'system' %}" title="{% trans "Configuration" %}">
<span class="glyphicon glyphicon-cog nav-icon"></span>
{% trans "Configuration" %}
</a>

View File

@ -54,7 +54,7 @@
{% else %}
<h4>
{% url 'apps:index' as apps_url %}
{% url 'apps' as apps_url %}
{% blocktrans trimmed %}
Enable some <a href="{{ apps_url }}">applications</a> to add
shortcuts to this page.

View File

@ -1,4 +1,4 @@
{% extends 'simple_service.html' %}
{% extends 'base.html' %}
{% comment %}
#
# This file is part of Plinth.
@ -17,3 +17,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load i18n %}
{% block content %}
<h2>{% trans "System Configuration" %}</h2>
<p>
{% blocktrans trimmed %}
Here you can administrate the underlying system of your {{ box_name }}.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
The options affect the {{ box_name }} at its most general level,
so be careful!
{% endblocktrans %}
</p>
{% endblock %}

View File

@ -46,14 +46,6 @@ class TestCfg(unittest.TestCase):
"""Cleanup after all tests are completed."""
cfg.read()
def test_read_main_menu(self):
"""Verify that the cfg.main_menu container is initially empty."""
# Menu should be empty before...
self.assertEqual(len(cfg.main_menu.items), 0)
cfg.read(self.test_config_file, self.test_config_dir)
# ...and after reading the config file
self.assertEqual(len(cfg.main_menu.items), 0)
def test_read_default_config_file(self):
"""Verify that the default config file can be read correctly."""
# Read the plinth.config file directly

View File

@ -25,6 +25,12 @@ from django.test import TestCase
from plinth import cfg
from plinth import context_processors as cp
from plinth import menu
def setUpModule(): # noqa
"""Setup all test cases by initializing menu module."""
menu.init()
class ContextProcessorsTestCase(TestCase):

View File

@ -24,6 +24,7 @@ from django.test import TestCase
from django.urls import reverse
import random
from plinth import menu as menu_module
from plinth.menu import Menu
@ -62,6 +63,22 @@ def dump_menu(menu):
class MenuTestCase(TestCase):
"""Verify the behavior of the Plinth Menu class."""
def test_init(self):
"""Verify that main_menu and essential items are created."""
menu_module.init()
main_menu = menu_module.main_menu
self.assertIsInstance(main_menu, Menu)
apps_menu = main_menu.get('apps')
self.assertEqual(apps_menu.label, '')
self.assertEqual(apps_menu.icon, 'glyphicon-download-alt')
self.assertEqual(str(apps_menu.url), '/apps/')
system_menu = main_menu.get('system')
self.assertEqual(system_menu.label, '')
self.assertEqual(system_menu.icon, 'glyphicon-cog')
self.assertEqual(str(system_menu.url), '/sys/')
def test_menu_creation_without_arguments(self):
"""Verify the Menu state without initialization parameters."""
menu = Menu()

View File

@ -20,8 +20,15 @@ Django URLconf file containing all urls
"""
from django.conf.urls import url
from django.views.generic import TemplateView
from . import views
urlpatterns = [
url(r'^$', views.index, name='index')
url(r'^$', views.index, name='index'),
url(r'^apps/$', TemplateView.as_view(template_name='apps.html'),
name='apps'),
url(r'^sys/$', TemplateView.as_view(template_name='system.html'),
name='system'),
]