mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
deluge: Use new setup mechanism
This commit is contained in:
parent
0e0b8318d0
commit
68881f720c
@ -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():
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
@ -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})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user