avahi: Use new setup mechanism

This commit is contained in:
Sunil Mohan Adapa 2016-02-12 14:18:20 +05:30
parent 83a56bba93
commit ad8fea5eb2
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
3 changed files with 29 additions and 23 deletions

View File

@ -24,24 +24,45 @@ from django.utils.translation import ugettext_lazy as _
from plinth import action_utils from plinth import action_utils
from plinth import cfg from plinth import cfg
from plinth import service as service_module from plinth import service as service_module
from plinth.utils import format_lazy
# pylint: disable=C0103 # pylint: disable=C0103
version = 1
is_essential = True
depends = ['system'] 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 service = None
def init(): def init():
"""Intialize the service discovery module.""" """Intialize the service discovery module."""
menu = cfg.main_menu.get('system:index') menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Service Discovery'), 'glyphicon-lamp', menu.add_urlname(title, 'glyphicon-lamp', 'avahi:index', 950)
'avahi:index', 950)
global service # pylint: disable=W0603 global service # pylint: disable=W0603
service = service_module.Service( service = service_module.Service(
'avahi', _('Service Discovery'), ['mdns'], 'avahi', title, ['mdns'], is_external=False, enabled=is_enabled())
is_external=False, enabled=is_enabled())
def setup(helper, old_version=False):
"""Install and configure the module."""
helper.install(['avahi-daemon'])
def is_enabled(): def is_enabled():

View File

@ -1,4 +1,4 @@
{% extends "base.html" %} {% extends "app.html" %}
{% comment %} {% comment %}
# #
# This file is part of Plinth. # This file is part of Plinth.
@ -21,21 +21,7 @@
{% load bootstrap %} {% load bootstrap %}
{% load i18n %} {% load i18n %}
{% block content %} {% block configuration %}
<h2>{% trans "Service Discovery" %}</h2>
<p>
{% 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 %}
</p>
<h3>{% trans "Status" %}</h3> <h3>{% trans "Status" %}</h3>

View File

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