From efa575b2041ff661aadd15b452a5e799ca5e973f Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Fri, 3 Nov 2017 18:11:38 +0530 Subject: [PATCH] Add clients to ServiceView Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/modules/deluge/urls.py | 10 ++-- plinth/modules/diaspora/views.py | 7 +-- plinth/modules/ikiwiki/views.py | 72 +++++++++++++++------------ plinth/modules/infinoted/__init__.py | 37 ++++++++------ plinth/modules/jsxc/views.py | 2 +- plinth/modules/matrixsynapse/views.py | 13 ++--- plinth/modules/minetest/views.py | 34 ++++++------- plinth/modules/mumble/__init__.py | 33 +++++++----- plinth/modules/quassel/__init__.py | 37 +++++++++----- plinth/modules/radicale/views.py | 15 +++--- plinth/modules/repro/__init__.py | 37 ++++++++------ plinth/modules/restore/urls.py | 10 ++-- plinth/modules/syncthing/urls.py | 1 + plinth/modules/tor/templates/tor.html | 2 + plinth/modules/tor/views.py | 26 +++++----- plinth/modules/transmission/views.py | 1 + plinth/modules/ttrss/urls.py | 16 +++--- plinth/templates/clients.html | 24 +++++---- plinth/templates/service.html | 6 +-- plinth/templates/setup.html | 3 +- plinth/views.py | 14 +++--- static/themes/default/css/plinth.css | 1 - 22 files changed, 224 insertions(+), 177 deletions(-) diff --git a/plinth/modules/deluge/urls.py b/plinth/modules/deluge/urls.py index d6dd6ae40..650c159a8 100644 --- a/plinth/modules/deluge/urls.py +++ b/plinth/modules/deluge/urls.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ URLs for the Deluge module. """ @@ -24,11 +23,12 @@ from django.conf.urls import url from plinth.modules import deluge from plinth.views import ServiceView - urlpatterns = [ - url(r'^apps/deluge/$', ServiceView.as_view( + url(r'^apps/deluge/$', + ServiceView.as_view( description=deluge.description, diagnostics_module_name="deluge", - service_id=deluge.managed_services[0] - ), name='index'), + clients=deluge.clients, + service_id=deluge.managed_services[0]), + name='index'), ] diff --git a/plinth/modules/diaspora/views.py b/plinth/modules/diaspora/views.py index 92aabf482..2626af62d 100644 --- a/plinth/modules/diaspora/views.py +++ b/plinth/modules/diaspora/views.py @@ -70,17 +70,18 @@ class DiasporaServiceView(ServiceView): def get_context_data(self, *args, **kwargs): context = super().get_context_data(**kwargs) context['domain_name'] = diaspora.get_configured_domain_name() + context['clients'] = diaspora.clients return context def get_initial(self): """Return the status of the service to fill in the form.""" return { 'is_enabled': - self.service.is_enabled(), + self.service.is_enabled(), 'is_user_registrations_enabled': - diaspora.is_user_registrations_enabled(), + diaspora.is_user_registrations_enabled(), 'is_running': - self.service.is_running() + self.service.is_running() } def form_valid(self, form): diff --git a/plinth/modules/ikiwiki/views.py b/plinth/modules/ikiwiki/views.py index a26b6e0b3..f5045e791 100644 --- a/plinth/modules/ikiwiki/views.py +++ b/plinth/modules/ikiwiki/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for configuring ikiwiki """ @@ -32,13 +31,16 @@ from plinth.modules import ikiwiki from .forms import IkiwikiCreateForm - -subsubmenu = [{'url': reverse_lazy('ikiwiki:index'), - 'text': ugettext_lazy('Configure')}, - {'url': reverse_lazy('ikiwiki:manage'), - 'text': ugettext_lazy('Manage')}, - {'url': reverse_lazy('ikiwiki:create'), - 'text': ugettext_lazy('Create')}] +subsubmenu = [{ + 'url': reverse_lazy('ikiwiki:index'), + 'text': ugettext_lazy('Configure') +}, { + 'url': reverse_lazy('ikiwiki:manage'), + 'text': ugettext_lazy('Manage') +}, { + 'url': reverse_lazy('ikiwiki:create'), + 'text': ugettext_lazy('Create') +}] class IkiwikiServiceView(views.ServiceView): @@ -52,6 +54,7 @@ class IkiwikiServiceView(views.ServiceView): """Return the context data for rendering the template view.""" context = super().get_context_data(**kwargs) context['subsubmenu'] = subsubmenu + context['clients'] = ikiwiki.clients return context @@ -60,10 +63,11 @@ def manage(request): sites = actions.run('ikiwiki', ['get-sites']).split('\n') sites = [name for name in sites if name != ''] - return TemplateResponse(request, 'ikiwiki_manage.html', - {'title': _('Manage Wikis and Blogs'), - 'subsubmenu': subsubmenu, - 'sites': sites}) + return TemplateResponse(request, 'ikiwiki_manage.html', { + 'title': _('Manage Wikis and Blogs'), + 'subsubmenu': subsubmenu, + 'sites': sites + }) def create(request): @@ -84,17 +88,21 @@ def create(request): site = form.cleaned_data['name'].replace(' ', '') frontpage.add_shortcut( - 'ikiwiki_' + site, site, url='/ikiwiki/' + site, - login_required=False, icon='ikiwiki') + 'ikiwiki_' + site, + site, + url='/ikiwiki/' + site, + login_required=False, + icon='ikiwiki') return redirect(reverse_lazy('ikiwiki:manage')) else: form = IkiwikiCreateForm(prefix='ikiwiki') - return TemplateResponse(request, 'ikiwiki_create.html', - {'title': _('Create Wiki or Blog'), - 'form': form, - 'subsubmenu': subsubmenu}) + return TemplateResponse(request, 'ikiwiki_create.html', { + 'title': _('Create Wiki or Blog'), + 'form': form, + 'subsubmenu': subsubmenu + }) def _create_wiki(request, name, admin_name, admin_password): @@ -102,13 +110,12 @@ def _create_wiki(request, name, admin_name, admin_password): try: actions.superuser_run( 'ikiwiki', - ['create-wiki', '--wiki_name', name, - '--admin_name', admin_name], + ['create-wiki', '--wiki_name', name, '--admin_name', admin_name], input=admin_password.encode()) messages.success(request, _('Created wiki {name}.').format(name=name)) except actions.ActionError as error: - messages.error(request, _('Could not create wiki: {error}') - .format(error=error)) + messages.error( + request, _('Could not create wiki: {error}').format(error=error)) def _create_blog(request, name, admin_name, admin_password): @@ -116,13 +123,12 @@ def _create_blog(request, name, admin_name, admin_password): try: actions.superuser_run( 'ikiwiki', - ['create-blog', '--blog_name', name, - '--admin_name', admin_name], + ['create-blog', '--blog_name', name, '--admin_name', admin_name], input=admin_password.encode()) messages.success(request, _('Created blog {name}.').format(name=name)) except actions.ActionError as error: - messages.error(request, _('Could not create blog: {error}') - .format(error=error)) + messages.error( + request, _('Could not create blog: {error}').format(error=error)) def delete(request, name): @@ -137,12 +143,14 @@ def delete(request, name): messages.success(request, _('{name} deleted.').format(name=name)) frontpage.remove_shortcut('ikiwiki_' + name) except actions.ActionError as error: - messages.error(request, _('Could not delete {name}: {error}') - .format(name=name, error=error)) + messages.error(request, + _('Could not delete {name}: {error}').format( + name=name, error=error)) return redirect(reverse_lazy('ikiwiki:manage')) - return TemplateResponse(request, 'ikiwiki_delete.html', - {'title': _('Delete Wiki or Blog'), - 'subsubmenu': subsubmenu, - 'name': name}) + return TemplateResponse(request, 'ikiwiki_delete.html', { + 'title': _('Delete Wiki or Blog'), + 'subsubmenu': subsubmenu, + 'name': name + }) diff --git a/plinth/modules/infinoted/__init__.py b/plinth/modules/infinoted/__init__.py index c1489de5f..6dcaf3e5c 100644 --- a/plinth/modules/infinoted/__init__.py +++ b/plinth/modules/infinoted/__init__.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for infinoted. """ @@ -32,7 +31,6 @@ from plinth.utils import format_lazy from plinth.views import ServiceView from .manifest import clients - version = 1 service = None @@ -47,7 +45,6 @@ short_description = _('Gobby Server') description = [ _('infinoted is a server for Gobby, a collaborative text editor.'), - format_lazy( _('To use it, download Gobby, ' 'desktop client and install it. Then start Gobby and select ' @@ -55,21 +52,25 @@ description = [ box_name=_(cfg.box_name)), ] - clients = clients def init(): """Initialize the infinoted module.""" menu = main_menu.get('apps') - menu.add_urlname(name, 'glyphicon-pencil', 'infinoted:index', short_description) + menu.add_urlname(name, 'glyphicon-pencil', 'infinoted:index', + short_description) global service setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup': service = service_module.Service( - managed_services[0], name, ports=['infinoted-plinth'], - is_external=True, enable=enable, disable=disable) + managed_services[0], + name, + ports=['infinoted-plinth'], + is_external=True, + enable=enable, + disable=disable) if service.is_enabled(): add_shortcut() @@ -79,6 +80,7 @@ class InfinotedServiceView(ServiceView): service_id = managed_services[0] diagnostics_module_name = "infinoted" description = description + clients = clients def setup(helper, old_version=None): @@ -88,19 +90,26 @@ def setup(helper, old_version=None): global service if service is None: service = service_module.Service( - managed_services[0], name, ports=['infinoted-plinth'], - is_external=True, enable=enable, disable=disable) + managed_services[0], + name, + ports=['infinoted-plinth'], + is_external=True, + enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) def add_shortcut(): - frontpage.add_shortcut('infinoted', name, - short_description=short_description, url=None, - details=description, - configure_url=reverse_lazy('infinoted:index'), - login_required=False) + frontpage.add_shortcut( + 'infinoted', + name, + short_description=short_description, + url=None, + details=description, + configure_url=reverse_lazy('infinoted:index'), + login_required=False) def enable(): diff --git a/plinth/modules/jsxc/views.py b/plinth/modules/jsxc/views.py index 9a886ff48..86f6b6a11 100644 --- a/plinth/modules/jsxc/views.py +++ b/plinth/modules/jsxc/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Views for the JSXC module """ @@ -33,6 +32,7 @@ class JSXCServiceView(ServiceView): template_name = 'jsxc.html' description = jsxc.description show_status_block = False + clients = jsxc.clients class JsxcView(TemplateView): diff --git a/plinth/modules/matrixsynapse/views.py b/plinth/modules/matrixsynapse/views.py index e9a65beaf..21b850853 100644 --- a/plinth/modules/matrixsynapse/views.py +++ b/plinth/modules/matrixsynapse/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Views for the Matrix Synapse module. """ @@ -79,13 +78,15 @@ class MatrixSynapseServiceView(ServiceView): """Add additional context data for template.""" context = super().get_context_data(*args, **kwargs) context['domain_name'] = matrixsynapse.get_configured_domain_name() + context['clients'] = matrixsynapse.clients return context def get_initial(self): """Return the values to fill in the form.""" initial = super().get_initial() initial.update({ - 'enable_public_registration': get_public_registration_status()}) + 'enable_public_registration': get_public_registration_status() + }) return initial def form_valid(self, form): @@ -112,13 +113,13 @@ class MatrixSynapseServiceView(ServiceView): if not pubreg_same: # note action public_registration restarts, if running now if new_config['enable_public_registration']: - actions.superuser_run('matrixsynapse', ['public_registration', - 'enable']) + actions.superuser_run('matrixsynapse', + ['public_registration', 'enable']) messages.success(self.request, _('Public registration enabled')) else: - actions.superuser_run('matrixsynapse', ['public_registration', - 'disable']) + actions.superuser_run('matrixsynapse', + ['public_registration', 'disable']) messages.success(self.request, _('Public registration disabled')) diff --git a/plinth/modules/minetest/views.py b/plinth/modules/minetest/views.py index 63d4b7148..2a684b414 100644 --- a/plinth/modules/minetest/views.py +++ b/plinth/modules/minetest/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Views for minetest module. """ @@ -23,20 +22,21 @@ from django.contrib import messages from django.utils.translation import ugettext_lazy as _ from plinth import actions +from plinth.modules import minetest from plinth.views import ServiceView - from . import description, managed_services, get_configuration from .forms import MinetestForm -class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors +class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors """A specialized view for configuring minetest.""" service_id = managed_services[0] diagnostics_module_name = "minetest" description = description show_status_block = True form_class = MinetestForm + clients = minetest.clients def get_initial(self): """Return the values to fill in the form.""" @@ -51,34 +51,30 @@ class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors if old_config['max_players'] != data['max_players'] \ and data['max_players'] != None: - actions.superuser_run( - 'minetest', - ['configure', '--max_players', str(data['max_players'])]) + actions.superuser_run('minetest', [ + 'configure', '--max_players', + str(data['max_players']) + ]) messages.success(self.request, _('Maximum players configuration updated')) if old_config['creative_mode'] != data['creative_mode']: value = 'true' if data['creative_mode'] else 'false' - actions.superuser_run( - 'minetest', - ['configure', '--creative_mode', value]) + actions.superuser_run('minetest', + ['configure', '--creative_mode', value]) messages.success(self.request, _('Creative mode configuration updated')) if old_config['enable_pvp'] != data['enable_pvp']: value = 'true' if data['enable_pvp'] else 'false' - actions.superuser_run( - 'minetest', - ['configure', '--enable_pvp', value]) - messages.success(self.request, - _('PVP configuration updated')) + actions.superuser_run('minetest', + ['configure', '--enable_pvp', value]) + messages.success(self.request, _('PVP configuration updated')) if old_config['enable_damage'] != data['enable_damage']: value = 'true' if data['enable_damage'] else 'false' - actions.superuser_run( - 'minetest', - ['configure', '--enable_damage', value]) - messages.success(self.request, - _('Damage configuration updated')) + actions.superuser_run('minetest', + ['configure', '--enable_damage', value]) + messages.success(self.request, _('Damage configuration updated')) return super().form_valid(form) diff --git a/plinth/modules/mumble/__init__.py b/plinth/modules/mumble/__init__.py index 5a6217931..f77237e72 100644 --- a/plinth/modules/mumble/__init__.py +++ b/plinth/modules/mumble/__init__.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module to configure Mumble server """ @@ -30,7 +29,6 @@ from plinth.menu import main_menu from plinth.views import ServiceView from .manifest import clients - version = 1 name = _('Mumble') @@ -46,7 +44,6 @@ managed_packages = ['mumble-server'] description = [ _('Mumble is an open source, low-latency, encrypted, high quality ' 'voice chat software.'), - _('You can connect to your Mumble server on the regular Mumble port ' '64738. Clients to connect to Mumble ' 'from your desktop and Android devices are available.') @@ -60,15 +57,19 @@ reserved_usernames = ['mumble-server'] def init(): """Intialize the Mumble module.""" menu = main_menu.get('apps') - menu.add_urlname(name, 'glyphicon-headphones', 'mumble:index', short_description) + menu.add_urlname(name, 'glyphicon-headphones', 'mumble:index', + short_description) global service setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup': service = service_module.Service( - managed_services[0], name, ports=['mumble-plinth'], + managed_services[0], + name, + ports=['mumble-plinth'], is_external=True, - enable=enable, disable=disable) + enable=enable, + disable=disable) if service.is_enabled(): add_shortcut() @@ -78,6 +79,7 @@ class MumbleServiceView(ServiceView): service_id = managed_services[0] diagnostics_module_name = "mumble" description = description + clients = clients def setup(helper, old_version=None): @@ -86,19 +88,24 @@ def setup(helper, old_version=None): global service if service is None: service = service_module.Service( - managed_services[0], name, ports=['mumble-plinth'], + managed_services[0], + name, + ports=['mumble-plinth'], is_external=True, - enable=enable, disable=disable) + enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) def add_shortcut(): - frontpage.add_shortcut('mumble', name, - short_description=short_description, - details=description, - configure_url=reverse_lazy('mumble:index'), - login_required=False) + frontpage.add_shortcut( + 'mumble', + name, + short_description=short_description, + details=description, + configure_url=reverse_lazy('mumble:index'), + login_required=False) def enable(): diff --git a/plinth/modules/quassel/__init__.py b/plinth/modules/quassel/__init__.py index 2230e8569..47928b0de 100644 --- a/plinth/modules/quassel/__init__.py +++ b/plinth/modules/quassel/__init__.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for Quassel. """ @@ -52,8 +51,8 @@ description = [ 'the client is disconnected. {box_name} can run the Quassel ' 'core service keeping you always online and one or more Quassel ' 'clients from a desktop or a mobile can be used to connect and ' - 'disconnect from it.'), box_name=_(cfg.box_name)), - + 'disconnect from it.'), + box_name=_(cfg.box_name)), _('You can connect to your Quassel core on the default Quassel port ' '4242. Clients to connect to Quassel from your ' 'desktop and ' @@ -69,14 +68,19 @@ reserved_usernames = ['quasselcore'] def init(): """Initialize the quassel module.""" menu = main_menu.get('apps') - menu.add_urlname(name, 'glyphicon-retweet', 'quassel:index', short_description) + menu.add_urlname(name, 'glyphicon-retweet', 'quassel:index', + short_description) global service setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup': service = service_module.Service( - managed_services[0], name, ports=['quassel-plinth'], - is_external=True, enable=enable, disable=disable) + managed_services[0], + name, + ports=['quassel-plinth'], + is_external=True, + enable=enable, + disable=disable) if service.is_enabled(): add_shortcut() @@ -86,6 +90,7 @@ class QuasselServiceView(ServiceView): service_id = managed_services[0] diagnostics_module_name = "quassel" description = description + clients = clients def setup(helper, old_version=None): @@ -94,18 +99,24 @@ def setup(helper, old_version=None): global service if service is None: service = service_module.Service( - managed_services[0], name, ports=['quassel-plinth'], - is_external=True, enable=enable, disable=disable) + managed_services[0], + name, + ports=['quassel-plinth'], + is_external=True, + enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) def add_shortcut(): - frontpage.add_shortcut('quassel', name, - short_description=short_description, - details=description, - configure_url=reverse_lazy('quassel:index'), - login_required=True) + frontpage.add_shortcut( + 'quassel', + name, + short_description=short_description, + details=description, + configure_url=reverse_lazy('quassel:index'), + login_required=True) def enable(): diff --git a/plinth/modules/radicale/views.py b/plinth/modules/radicale/views.py index da588689f..cac231a9f 100644 --- a/plinth/modules/radicale/views.py +++ b/plinth/modules/radicale/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Views for radicale module. """ @@ -23,6 +22,7 @@ from django.contrib import messages from django.utils.translation import ugettext_lazy as _ from plinth import actions +from plinth.modules import radicale from plinth.views import ServiceView from . import description, get_rights_value, managed_services @@ -31,10 +31,11 @@ from .forms import RadicaleForm class RadicaleServiceView(ServiceView): """A specialized view for configuring radicale service.""" - service_id = managed_services[0] - form_class = RadicaleForm - diagnostics_module_name = 'radicale' + clients = radicale.clients description = description + diagnostics_module_name = 'radicale' + form_class = RadicaleForm + service_id = managed_services[0] def get_initial(self): """Return the values to fill in the form.""" @@ -46,9 +47,9 @@ class RadicaleServiceView(ServiceView): """Change the access control of Radicale service.""" data = form.cleaned_data if get_rights_value() != data['access_rights']: - actions.superuser_run( - 'radicale', - ['configure', '--rights_type', data['access_rights']]) + actions.superuser_run('radicale', [ + 'configure', '--rights_type', data['access_rights'] + ]) messages.success(self.request, _('Access rights configuration updated')) return super().form_valid(form) diff --git a/plinth/modules/repro/__init__.py b/plinth/modules/repro/__init__.py index 01b3500a2..441d5e917 100644 --- a/plinth/modules/repro/__init__.py +++ b/plinth/modules/repro/__init__.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for repro. """ @@ -47,12 +46,10 @@ description = [ 'can use to let their presence known. It also acts as a proxy to ' 'federate SIP communications to other servers on the Internet similar ' 'to email.'), - _('To make SIP calls, a client application is needed. Available clients ' 'include Jitsi (for computers) and ' ' ' 'CSipSimple (for Android phones).'), - _('Note: Before using repro, domains and users will ' 'need to be configured using the ' 'web-based configuration panel. Users in the admin group ' @@ -71,24 +68,29 @@ service = None def init(): """Initialize the repro module.""" menu = main_menu.get('apps') - menu.add_urlname(name, 'glyphicon-phone-alt', 'repro:index', short_description) + menu.add_urlname(name, 'glyphicon-phone-alt', 'repro:index', + short_description) global service setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup': service = service_module.Service( - managed_services[0], name, + managed_services[0], + name, ports=['sip', 'sips', 'rtp-plinth'], - is_external=True, enable=enable, disable=disable) + is_external=True, + enable=enable, + disable=disable) if service.is_enabled(): add_shortcut() class ReproServiceView(ServiceView): - service_id = managed_services[0] - diagnostics_module_name = "repro" + clients = clients description = description + diagnostics_module_name = "repro" + service_id = managed_services[0] def setup(helper, old_version=None): @@ -98,19 +100,24 @@ def setup(helper, old_version=None): global service if service is None: service = service_module.Service( - managed_services[0], name, + managed_services[0], + name, ports=['sip', 'sips', 'rtp-plinth'], - is_external=True, enable=enable, disable=disable) + is_external=True, + enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) def add_shortcut(): - frontpage.add_shortcut('repro', name, - short_description=short_description, - details=description, - configure_url=reverse_lazy('repro:index'), - login_required=True) + frontpage.add_shortcut( + 'repro', + name, + short_description=short_description, + details=description, + configure_url=reverse_lazy('repro:index'), + login_required=True) def enable(): diff --git a/plinth/modules/restore/urls.py b/plinth/modules/restore/urls.py index e68aa4662..38c61e6a9 100644 --- a/plinth/modules/restore/urls.py +++ b/plinth/modules/restore/urls.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ URLs for the reStore module. """ @@ -24,10 +23,11 @@ from django.conf.urls import url from plinth.views import ServiceView from plinth.modules import restore - urlpatterns = [ - url(r'^apps/restore/$', ServiceView.as_view( + url(r'^apps/restore/$', + ServiceView.as_view( service_id=restore.managed_services[0], - description=restore.description - ), name='index'), + description=restore.description, + clients=restore.clients), + name='index'), ] diff --git a/plinth/modules/syncthing/urls.py b/plinth/modules/syncthing/urls.py index 394f62b1e..61e8ad864 100644 --- a/plinth/modules/syncthing/urls.py +++ b/plinth/modules/syncthing/urls.py @@ -29,6 +29,7 @@ urlpatterns = [ service_id=syncthing.managed_services[0], diagnostics_module_name='syncthing', description=syncthing.description, + clients=syncthing.clients, show_status_block=True), name='index'), ] diff --git a/plinth/modules/tor/templates/tor.html b/plinth/modules/tor/templates/tor.html index 736ec84ad..5e66835f8 100644 --- a/plinth/modules/tor/templates/tor.html +++ b/plinth/modules/tor/templates/tor.html @@ -32,6 +32,8 @@ {% block configuration %} + {% include "clients.html" with clients=clients %} +

{% trans "Status" %}

{% if config_running %} diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index d9374f1e1..c444c3a30 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ Plinth module for configuring Tor. """ @@ -28,7 +27,6 @@ from plinth import actions from plinth.errors import ActionError from plinth.modules import tor - config_process = None @@ -50,12 +48,14 @@ def index(request): else: form = TorForm(initial=status, prefix='tor') - return TemplateResponse(request, 'tor.html', - {'title': tor.name, - 'description': tor.description, - 'status': status, - 'config_running': bool(config_process), - 'form': form}) + return TemplateResponse(request, 'tor.html', { + 'title': tor.name, + 'description': tor.description, + 'clients': tor.clients, + 'status': status, + 'config_running': bool(config_process), + 'form': form + }) def _apply_changes(request, old_status, new_status): @@ -63,8 +63,10 @@ def _apply_changes(request, old_status, new_status): try: __apply_changes(request, old_status, new_status) except ActionError as exception: - messages.error(request, _('Action error: {0} [{1}] [{2}]').format( - exception.args[0], exception.args[1], exception.args[2])) + messages.error(request, + _('Action error: {0} [{1}] [{2}]').format( + exception.args[0], exception.args[1], + exception.args[2])) def __apply_changes(request, old_status, new_status): @@ -111,8 +113,8 @@ def __apply_changes(request, old_status, new_status): needs_restart = True if old_status['upstream_bridges'] != new_status['upstream_bridges']: - arguments.extend(['--upstream-bridges', - new_status['upstream_bridges']]) + arguments.extend( + ['--upstream-bridges', new_status['upstream_bridges']]) needs_restart = True if old_status['enabled'] != new_status['enabled']: diff --git a/plinth/modules/transmission/views.py b/plinth/modules/transmission/views.py index 3fc0d229e..7d7c5c521 100644 --- a/plinth/modules/transmission/views.py +++ b/plinth/modules/transmission/views.py @@ -34,6 +34,7 @@ logger = logging.getLogger(__name__) class TransmissionServiceView(views.ServiceView): """Serve configuration page.""" + clients = transmission.clients description = transmission.description diagnostics_module_name = 'transmission' form_class = TransmissionForm diff --git a/plinth/modules/ttrss/urls.py b/plinth/modules/ttrss/urls.py index 8e51b4633..5526d276f 100644 --- a/plinth/modules/ttrss/urls.py +++ b/plinth/modules/ttrss/urls.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ URLs for the Tiny Tiny RSS module. """ @@ -24,12 +23,13 @@ from django.conf.urls import url from plinth.views import ServiceView from plinth.modules import ttrss - urlpatterns = [ - url(r'^apps/ttrss/$', ServiceView.as_view( - service_id=ttrss.managed_services[0], - diagnostics_module_name="ttrss", - description=ttrss.description, - show_status_block=True - ), name='index'), + url(r'^apps/ttrss/$', + ServiceView.as_view( + service_id=ttrss.managed_services[0], + diagnostics_module_name="ttrss", + description=ttrss.description, + clients=ttrss.clients, + show_status_block=True), + name='index'), ] diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index 213fb4f12..778a729b0 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -20,18 +20,20 @@ {% load i18n %} {% load plinth_extras %} -{% if module.clients %} - +{% if clients %} +

+ +

-{% if module.clients|has_web_clients %} +{% if clients|has_web_clients %}

{% trans "Web Clients" %}:

    - {% for client in module.clients %} + {% for client in clients %} {% if client|has_web_clients %} {% for platform in client.platforms %} {% if platform.type == 'web' %} @@ -46,12 +48,12 @@
{% endif %} -{% if module.clients|has_desktop_clients %} +{% if clients|has_desktop_clients %}
{% load static %}

{% trans "Desktop Clients" %}:

    - {% for client in module.clients %} + {% for client in clients %} {% if client|has_desktop_clients %}
  • {{ client.name }}
  • @@ -77,12 +79,12 @@
    {% endif %} -{% if module.clients|has_mobile_clients %} +{% if clients|has_mobile_clients %}
    {% load static %}

    {% trans "Mobile Clients" %}:

      - {% for client in module.clients %} + {% for client in clients %} {% if client|has_mobile_clients %}
    • {{ client.name }}
    • diff --git a/plinth/templates/service.html b/plinth/templates/service.html index 31908381e..0025d72c8 100644 --- a/plinth/templates/service.html +++ b/plinth/templates/service.html @@ -34,6 +34,8 @@ {% endfor %} {% endblock %} + {% include "clients.html" with clients=clients %} + {% block status %} {% if show_status_block %}

      {% trans "Status" %}

      @@ -75,7 +77,3 @@ {% endblock %} {% endblock %} - - -{% include "clients.html" with clients=service.clients %} - diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html index ae8172c3a..763ee1c84 100644 --- a/plinth/templates/setup.html +++ b/plinth/templates/setup.html @@ -38,6 +38,8 @@

      {{ paragraph|safe }}

      {% endfor %} + {% include "clients.html" with clients=setup_helper.module.clients %} + {% if not setup_helper.current_operation %} {% if setup_helper.get_state == 'needs-setup' %} @@ -119,6 +121,5 @@ {% endif %} {% endif %} - {% include "clients.html" with module=setup_helper.module %} {% endblock %} diff --git a/plinth/views.py b/plinth/views.py index efb8b363f..df314c902 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -65,9 +65,7 @@ def system_index(request): class ServiceView(FormView): """A generic view for configuring simple services.""" - service_id = None - form_class = forms.ServiceForm - template_name = 'service.html' + clients = [] # Set diagnostics_module_name to the module name to show diagnostics button diagnostics_module_name = "" # List of paragraphs describing the service @@ -75,7 +73,10 @@ class ServiceView(FormView): # Display the 'status' block of the service.html template # This block uses information from service.is_running. This method is # optional, so allow not showing this block here. + form_class = forms.ServiceForm show_status_block = True + service_id = None + template_name = 'service.html' @property def success_url(self): @@ -126,10 +127,9 @@ class ServiceView(FormView): """Add service to the context data.""" context = super().get_context_data(*args, **kwargs) context['service'] = self.service - if self.diagnostics_module_name: - context['diagnostics_module_name'] = self.diagnostics_module_name - if self.description: - context['description'] = self.description + context['clients'] = self.clients + context['diagnostics_module_name'] = self.diagnostics_module_name + context['description'] = self.description context['show_status_block'] = self.show_status_block return context diff --git a/static/themes/default/css/plinth.css b/static/themes/default/css/plinth.css index 35e14ca92..cc467f9be 100644 --- a/static/themes/default/css/plinth.css +++ b/static/themes/default/css/plinth.css @@ -125,7 +125,6 @@ footer license-info p{ } .clients-info li { - float: left; padding-left: 15px; padding-bottom: 5px; }