deluge, ikiwiki: Notify when service is enabled/disabled.

This commit is contained in:
James Valleroy 2015-06-09 20:51:10 -04:00 committed by Sunil Mohan Adapa
parent 2871519322
commit a2fdd879d9
4 changed files with 28 additions and 0 deletions

View File

@ -21,14 +21,26 @@ Plinth module to configure a Deluge web client.
from gettext import gettext as _
from plinth import actions
from plinth import cfg
from plinth import service as service_module
depends = ['plinth.modules.apps']
service = None
def init():
"""Initialize the Deluge module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('BitTorrent (Deluge)'), 'glyphicon-magnet',
'deluge:index', 60)
output = actions.run('deluge', ['get-enabled'])
enabled = (output.strip() == 'yes')
global service
service = service_module.Service(
'deluge', _('Deluge BitTorrent'), ['http', 'https'],
is_external=True, enabled=enabled)

View File

@ -27,6 +27,7 @@ from gettext import gettext as _
from .forms import DelugeForm
from plinth import actions
from plinth import package
from plinth.modules import deluge
def on_install():
@ -79,6 +80,7 @@ def _apply_changes(request, old_status, new_status):
if old_status['enabled'] != new_status['enabled']:
sub_command = 'enable' if new_status['enabled'] else 'disable'
actions.superuser_run('deluge', [sub_command])
deluge.service.notify_enabled(None, new_status['enabled'])
modified = True
if modified:

View File

@ -21,14 +21,26 @@ Plinth module to configure ikiwiki
from gettext import gettext as _
from plinth import actions
from plinth import cfg
from plinth import service as service_module
depends = ['plinth.modules.apps']
service = None
def init():
"""Initialize the ikiwiki module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('Wiki & Blog (Ikiwiki)'), 'glyphicon-edit',
'ikiwiki:index', 38)
output = actions.run('ikiwiki', ['get-enabled'])
enabled = (output.strip() == 'yes')
global service
service = service_module.Service(
'ikiwiki', _('ikiwiki wikis and blogs'), ['http', 'https'],
is_external=True, enabled=enabled)

View File

@ -29,6 +29,7 @@ from gettext import gettext as _
from .forms import IkiwikiForm, IkiwikiCreateForm
from plinth import actions
from plinth import package
from plinth.modules import ikiwiki
subsubmenu = [{'url': reverse_lazy('ikiwiki:index'),
@ -88,6 +89,7 @@ def _apply_changes(request, old_status, new_status):
if old_status['enabled'] != new_status['enabled']:
sub_command = 'enable' if new_status['enabled'] else 'disable'
actions.superuser_run('ikiwiki', [sub_command])
ikiwiki.service.notify_enabled(None, new_status['enabled'])
modified = True
if modified: