mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
transmission: Use new setup mechanism
This commit is contained in:
parent
ac558568ba
commit
065d6c4c0a
@ -20,27 +20,51 @@ Plinth module to configure Transmission server
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import json
|
||||
|
||||
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 (Transmission)')
|
||||
|
||||
description = [
|
||||
_('BitTorrent is a peer-to-peer file sharing protocol. '
|
||||
'Transmission daemon handles Bitorrent file sharing. Note that '
|
||||
'BitTorrent is not anonymous.')
|
||||
]
|
||||
|
||||
service = None
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the Transmission module."""
|
||||
menu = cfg.main_menu.get('apps:index')
|
||||
menu.add_urlname(_('BitTorrent (Transmission)'), 'glyphicon-save',
|
||||
'transmission:index', 300)
|
||||
menu.add_urlname(title, 'glyphicon-save', 'transmission:index', 300)
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
'transmission', _('Transmission BitTorrent'), ['http', 'https'],
|
||||
is_external=True, enabled=is_enabled())
|
||||
'transmission', title, ['http', 'https'], is_external=True,
|
||||
enabled=is_enabled())
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(['transmission-daemon'])
|
||||
|
||||
new_configuration = {'rpc-whitelist-enabled': False}
|
||||
helper.call('post', actions.superuser_run, 'transmission',
|
||||
['merge-configuration'],
|
||||
input=json.dumps(new_configuration).encode())
|
||||
|
||||
helper.call('post', actions.superuser_run, 'transmission', ['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,17 +21,7 @@
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "BitTorrent (Transmission)" %}</h2>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
BitTorrent is a peer-to-peer file sharing protocol.
|
||||
Transmission daemon handles Bitorrent file sharing. Note that
|
||||
BitTorrent is not anonymous.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% block configuration %}
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
|
||||
@ -28,7 +28,6 @@ import socket
|
||||
|
||||
from .forms import TransmissionForm
|
||||
from plinth import actions
|
||||
from plinth import package
|
||||
from plinth.modules import transmission
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -36,17 +35,6 @@ logger = logging.getLogger(__name__)
|
||||
TRANSMISSION_CONFIG = '/etc/transmission-daemon/settings.json'
|
||||
|
||||
|
||||
def on_install():
|
||||
"""Enable transmission as soon as it is installed."""
|
||||
new_configuration = {'rpc-whitelist-enabled': False}
|
||||
actions.superuser_run('transmission', ['merge-configuration'],
|
||||
input=json.dumps(new_configuration).encode())
|
||||
|
||||
actions.superuser_run('transmission', ['enable'])
|
||||
transmission.service.notify_enabled(None, True)
|
||||
|
||||
|
||||
@package.required(['transmission-daemon'], on_install=on_install)
|
||||
def index(request):
|
||||
"""Serve configuration page."""
|
||||
status = get_status()
|
||||
@ -64,7 +52,8 @@ def index(request):
|
||||
form = TransmissionForm(initial=status, prefix='transmission')
|
||||
|
||||
return TemplateResponse(request, 'transmission.html',
|
||||
{'title': _('BitTorrent (Transmission)'),
|
||||
{'title': transmission.title,
|
||||
'description': transmission.description,
|
||||
'status': status,
|
||||
'form': form})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user