deluge: Use new setup mechanism

This commit is contained in:
Sunil Mohan Adapa 2016-02-12 14:34:13 +05:30
parent 0e0b8318d0
commit 68881f720c
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
3 changed files with 28 additions and 28 deletions

View File

@ -21,26 +21,46 @@ Plinth module to configure a Deluge web client.
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
version = 1
depends = ['apps']
title = _('BitTorrent Web Client (Deluge)')
description = [
_('Deluge is a BitTorrent client that features a Web UI.'),
_('When enabled, the Deluge web client will be available from '
'<a href="/deluge">/deluge</a> path on the web server. The '
'default password is \'deluge\', but you should log in and change '
'it immediately after enabling this service.')
]
service = None
def init():
"""Initialize the Deluge module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('BitTorrent (Deluge)'), 'glyphicon-magnet',
'deluge:index', 200)
menu.add_urlname(title, 'glyphicon-magnet', 'deluge:index', 200)
global service
service = service_module.Service(
'deluge', _('Deluge BitTorrent'), ['http', 'https'],
is_external=True, enabled=is_enabled())
'deluge', title, ['http', 'https'], is_external=True,
enabled=is_enabled())
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(['deluged', 'deluge-web'])
helper.call('post', actions.superuser_run, 'deluge', ['enable'])
helper.call('post', service.notify_enabled, None, True)
def is_enabled():

View File

@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "app.html" %}
{% comment %}
#
# This file is part of Plinth.
@ -21,20 +21,7 @@
{% load bootstrap %}
{% load i18n %}
{% block content %}
<h2>{% trans "BitTorrent Web Client (Deluge)" %}</h2>
<p>{% trans "Deluge is a BitTorrent client that features a Web UI." %}</p>
<p>
{% blocktrans trimmed %}
When enabled, the Deluge web client will be available from
<a href="/deluge">/deluge</a> path on the web server. The
default password is 'deluge', but you should log in and change
it immediately after enabling this service.
{% endblocktrans %}
</p>
{% block configuration %}
<h3>{% trans "Status" %}</h3>

View File

@ -25,17 +25,9 @@ from django.utils.translation import ugettext as _
from .forms import DelugeForm
from plinth import actions
from plinth import package
from plinth.modules import deluge
def on_install():
"""Tasks to run after package install."""
actions.superuser_run('deluge', ['enable'])
deluge.service.notify_enabled(None, True)
@package.required(['deluged', 'deluge-web'], on_install=on_install)
def index(request):
"""Serve configuration page."""
status = get_status()
@ -53,7 +45,8 @@ def index(request):
form = DelugeForm(initial=status, prefix='deluge')
return TemplateResponse(request, 'deluge.html',
{'title': _('BitTorrent (Deluge)'),
{'title': deluge.title,
'description': deluge.description,
'status': status,
'form': form})