From ad8fea5eb2a8fe8ab67d435d36798c8e2dfc826b Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 12 Feb 2016 14:18:20 +0530 Subject: [PATCH] avahi: Use new setup mechanism --- plinth/modules/avahi/__init__.py | 29 +++++++++++++++++++---- plinth/modules/avahi/templates/avahi.html | 18 ++------------ plinth/modules/avahi/views.py | 5 ++-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/plinth/modules/avahi/__init__.py b/plinth/modules/avahi/__init__.py index 84987cdc7..c4c0970bc 100644 --- a/plinth/modules/avahi/__init__.py +++ b/plinth/modules/avahi/__init__.py @@ -24,24 +24,45 @@ from django.utils.translation import ugettext_lazy as _ from plinth import action_utils from plinth import cfg from plinth import service as service_module +from plinth.utils import format_lazy # pylint: disable=C0103 +version = 1 + +is_essential = True + depends = ['system'] +title = _('Service Discovery') + +description = [ + format_lazy( + _('Service discovery allows other devices on the network to ' + 'discover your {{ box_name }} and services running on it. It ' + 'also allows {{ box_name }} to discover other devices and ' + 'services running on your local network. Service discovery is ' + 'not essential and works only on internal networks. It may be ' + 'disabled to improve security especially when connecting to a ' + 'hostile local network.'), box_name=_(cfg.box_name)) +] + service = None def init(): """Intialize the service discovery module.""" menu = cfg.main_menu.get('system:index') - menu.add_urlname(_('Service Discovery'), 'glyphicon-lamp', - 'avahi:index', 950) + menu.add_urlname(title, 'glyphicon-lamp', 'avahi:index', 950) global service # pylint: disable=W0603 service = service_module.Service( - 'avahi', _('Service Discovery'), ['mdns'], - is_external=False, enabled=is_enabled()) + 'avahi', title, ['mdns'], is_external=False, enabled=is_enabled()) + + +def setup(helper, old_version=False): + """Install and configure the module.""" + helper.install(['avahi-daemon']) def is_enabled(): diff --git a/plinth/modules/avahi/templates/avahi.html b/plinth/modules/avahi/templates/avahi.html index c3d1b98d7..193a1ac07 100644 --- a/plinth/modules/avahi/templates/avahi.html +++ b/plinth/modules/avahi/templates/avahi.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of Plinth. @@ -21,21 +21,7 @@ {% load bootstrap %} {% load i18n %} -{% block content %} - -

{% trans "Service Discovery" %}

- -

- {% blocktrans trimmed %} - Service discovery allows other devices on the network to - discover your {{ box_name }} and services running on it. It - also allows {{ box_name }} to discover other devices and - services running on your local network. Service discovery is - not essential and works only on internal networks. It may be - disabled to improve security especially when connecting to a - hostile local network. - {% endblocktrans %} -

+{% block configuration %}

{% trans "Status" %}

diff --git a/plinth/modules/avahi/views.py b/plinth/modules/avahi/views.py index e8fa4b61c..77751abca 100644 --- a/plinth/modules/avahi/views.py +++ b/plinth/modules/avahi/views.py @@ -26,14 +26,12 @@ import logging from .forms import ServiceDiscoveryForm from plinth import actions -from plinth import package from plinth.modules import avahi logger = logging.getLogger(__name__) # pylint: disable=C0103 -@package.required(['avahi-daemon']) def index(request): """Serve configuration page.""" status = get_status() @@ -50,7 +48,8 @@ def index(request): form = ServiceDiscoveryForm(initial=status, prefix='avahi') return TemplateResponse(request, 'avahi.html', - {'title': _('Service Discovery'), + {'title': avahi.title, + 'description': avahi.description, 'status': status, 'form': form})