datetime: Use new setup mechanism

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

View File

@ -27,21 +27,36 @@ from plinth import cfg
from plinth import service as service_module from plinth import service as service_module
version = 1
is_essential = True
depends = ['system'] depends = ['system']
title = _('Date & Time')
description = [
_('Network time server is a program that maintians the system time '
'in synchronization with servers on the Internet.')
]
service = None service = None
def init(): def init():
"""Intialize the date/time module.""" """Intialize the date/time module."""
menu = cfg.main_menu.get('system:index') menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Date & Time'), 'glyphicon-time', menu.add_urlname(title, 'glyphicon-time', 'datetime:index', 900)
'datetime:index', 900)
global service global service
service = service_module.Service( service = service_module.Service(
'ntp', _('Network Time Server'), 'ntp', title, is_external=False, enabled=is_enabled())
is_external=False, enabled=is_enabled())
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(['ntp'])
helper.call('post', service.notify_enabled, None, True)
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,16 +21,7 @@
{% load bootstrap %} {% load bootstrap %}
{% load i18n %} {% load i18n %}
{% block content %} {% block configuration %}
<h2>{% trans "Date & Time" %}</h2>
<p>
{% blocktrans trimmed %}
Network time server is a program that maintians the system time
in synchronization with servers on the Internet.
{% endblocktrans %}
</p>
<h3>{% trans "Status" %}</h3> <h3>{% trans "Status" %}</h3>

View File

@ -26,18 +26,11 @@ import logging
from .forms import DateTimeForm from .forms import DateTimeForm
from plinth import actions from plinth import actions
from plinth import package
from plinth.modules import datetime from plinth.modules import datetime
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def on_install():
"""Notify that the service is now enabled."""
datetime.service.notify_enabled(None, True)
@package.required(['ntp'], on_install=on_install)
def index(request): def index(request):
"""Serve configuration page.""" """Serve configuration page."""
status = get_status() status = get_status()
@ -55,7 +48,8 @@ def index(request):
form = DateTimeForm(initial=status, prefix='datetime') form = DateTimeForm(initial=status, prefix='datetime')
return TemplateResponse(request, 'datetime.html', return TemplateResponse(request, 'datetime.html',
{'title': _('Date & Time'), {'title': datetime.title,
'description': datetime.description,
'status': status, 'status': status,
'form': form}) 'form': form})