From 0e0b8318d0e362bd7bad04941e1ab0a1adb9bc72 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 12 Feb 2016 14:26:57 +0530 Subject: [PATCH] datetime: Use new setup mechanism --- plinth/modules/datetime/__init__.py | 23 +++++++++++++++---- .../modules/datetime/templates/datetime.html | 13 ++--------- plinth/modules/datetime/views.py | 10 ++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plinth/modules/datetime/__init__.py b/plinth/modules/datetime/__init__.py index 1ca8f6244..0c200169a 100644 --- a/plinth/modules/datetime/__init__.py +++ b/plinth/modules/datetime/__init__.py @@ -27,21 +27,36 @@ from plinth import cfg from plinth import service as service_module +version = 1 + +is_essential = True + 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 def init(): """Intialize the date/time module.""" menu = cfg.main_menu.get('system:index') - menu.add_urlname(_('Date & Time'), 'glyphicon-time', - 'datetime:index', 900) + menu.add_urlname(title, 'glyphicon-time', 'datetime:index', 900) global service service = service_module.Service( - 'ntp', _('Network Time Server'), - is_external=False, enabled=is_enabled()) + 'ntp', title, 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(): diff --git a/plinth/modules/datetime/templates/datetime.html b/plinth/modules/datetime/templates/datetime.html index bce9499f2..d0a7aa407 100644 --- a/plinth/modules/datetime/templates/datetime.html +++ b/plinth/modules/datetime/templates/datetime.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of Plinth. @@ -21,16 +21,7 @@ {% load bootstrap %} {% load i18n %} -{% block content %} - -

{% trans "Date & Time" %}

- -

- {% blocktrans trimmed %} - Network time server is a program that maintians the system time - in synchronization with servers on the Internet. - {% endblocktrans %} -

+{% block configuration %}

{% trans "Status" %}

diff --git a/plinth/modules/datetime/views.py b/plinth/modules/datetime/views.py index 51ea7e57c..f687e1506 100644 --- a/plinth/modules/datetime/views.py +++ b/plinth/modules/datetime/views.py @@ -26,18 +26,11 @@ import logging from .forms import DateTimeForm from plinth import actions -from plinth import package from plinth.modules import datetime 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): """Serve configuration page.""" status = get_status() @@ -55,7 +48,8 @@ def index(request): form = DateTimeForm(initial=status, prefix='datetime') return TemplateResponse(request, 'datetime.html', - {'title': _('Date & Time'), + {'title': datetime.title, + 'description': datetime.description, 'status': status, 'form': form})