mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-17 11:10:23 +00:00
datetime: Use new setup mechanism
This commit is contained in:
parent
9d1a940d7c
commit
0e0b8318d0
@ -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():
|
||||
|
||||
@ -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 %}
|
||||
|
||||
<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>
|
||||
{% block configuration %}
|
||||
|
||||
<h3>{% trans "Status" %}</h3>
|
||||
|
||||
|
||||
@ -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})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user