mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- Introduce new API to mark an app that it can't be disabled. - Mark jsxc, storage, config, upgrade and firewall apps as can't be disabled. - Fixed functional tests - Replaced AppForm with forms.Form in all modules' forms.py. - Remove app.template.js. - Remove unused styles. - Remove app status checks in form_valid of Deluge, Diaspora, Matrix, Ejabberd, MediaWiki, Storage, Transmission, Quassel - Purge unused is_enabled context variables (Ikiwiki) - ejabberd: Minor cleanup in template - jsxc: Cleanup unneeded overrides - tahoe: Cleanup unnecessary overrides Tests performed: - For all apps affected, test enable/disable button works and submitting configuration form works: with changes updates message and without changes 'settings unchanged' message. - avahi - bind - cockpit - SKIP: coquelicot - datetime - deluge - SKIP: diaspora - ejabberd - gitweb - i2p - infinoted - ikiwiki - matrixsynapse - mediawiki - minetest - minidlna - mldonkey - mumble - pagekite - privoxy - quassel - radicale - roundcube - SKIP: samba - searx - SKIP: shaarli - shadowsocks - ssh - tahoe - transmission - FAIL: tt-rss (not installable) - wireguard - Deluge test that configuration changes when app is disabled work - Quassel test that setting the domain works when app is diabled - Transmission test that setting the domain works when app is diabled - Ikiwiki create form works properly - Enable/disable button appears as expected when enabled and when disabled - Enable/disable button works without Javascript - Functional tests work for affected apps, Tor and OpenVPN - AppForm is removed from developer documentation - Forms reference - Customizing tutorial - Test all apps using directory select form - Transmission - Deluge - Visit each template that overrides block configuration and ensure that it is loaded properly and the display is as expected. - All apps that use AppView that are not tested above should not have an enable/disable button. That is JSXC, update, config, firewall, storage, users. Signed-off-by: Alice Kile <buoyantair@protonmail.com> Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Forms for configuring date and time
|
|
"""
|
|
|
|
import logging
|
|
import subprocess
|
|
|
|
from django import forms
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DateTimeForm(forms.Form):
|
|
"""Date/time configuration form."""
|
|
time_zone = forms.ChoiceField(
|
|
label=_('Time Zone'),
|
|
help_text=_('Set your time zone to get accurate timestamps. '
|
|
'This will set the system-wide time zone.'))
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
"""Initialize the date/time form."""
|
|
forms.Form.__init__(self, *args, **kwargs)
|
|
|
|
time_zone_options = [(zone, zone) for zone in self.get_time_zones()]
|
|
# Show not-set option only when time zone is not set
|
|
current_time_zone = self.initial.get('time_zone')
|
|
if current_time_zone == 'none':
|
|
time_zone_options.insert(0, ('none', _('-- no time zone set --')))
|
|
elif (current_time_zone, current_time_zone) not in time_zone_options:
|
|
time_zone_options.insert(0, (current_time_zone, current_time_zone))
|
|
|
|
self.fields['time_zone'].choices = time_zone_options
|
|
|
|
@staticmethod
|
|
def get_time_zones():
|
|
"""Return the list time zones."""
|
|
command = ['timedatectl', 'list-timezones']
|
|
try:
|
|
process = subprocess.run(command, stdout=subprocess.PIPE,
|
|
check=True)
|
|
except subprocess.CalledProcessError as exception:
|
|
logger.exception('Error getting time zones: %s', exception)
|
|
return []
|
|
|
|
output = process.stdout.decode()
|
|
return output.splitlines()
|