mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
config: Hide time zone not-set option normally
- After a time zone is set, don't show the option 'No time zone set' any more. - Change the label to 'no time zone set' - Update the help text to 'time zone' instead of 'timezone'.
This commit is contained in:
parent
d93fbba51f
commit
cc365fb2eb
@ -62,8 +62,8 @@ class ConfigurationForm(forms.Form):
|
|||||||
"""Main system configuration form"""
|
"""Main system configuration form"""
|
||||||
time_zone = forms.ChoiceField(
|
time_zone = forms.ChoiceField(
|
||||||
label=_('Time Zone'),
|
label=_('Time Zone'),
|
||||||
help_text=_('Set your timezone to get accurate timestamps. \
|
help_text=_('Set your time zone to get accurate timestamps. \
|
||||||
This information will be used to set your systemwide timezone'))
|
This will set the systemwide time zone.'))
|
||||||
|
|
||||||
# We're more conservative than RFC 952 and RFC 1123
|
# We're more conservative than RFC 952 and RFC 1123
|
||||||
hostname = TrimmedCharField(
|
hostname = TrimmedCharField(
|
||||||
@ -91,8 +91,9 @@ separated by dots.'),
|
|||||||
|
|
||||||
timezone_options = [(zone, zone)
|
timezone_options = [(zone, zone)
|
||||||
for zone in self.get_time_zones()]
|
for zone in self.get_time_zones()]
|
||||||
|
# Show not-set option only when time zone is not set
|
||||||
timezone_options.append(('none', _('No timezone set')))
|
if self.initial.get('time_zone') == 'none':
|
||||||
|
timezone_options.insert(0, ('none', _('-- no time zone set --')))
|
||||||
|
|
||||||
self.fields['time_zone'].choices = timezone_options
|
self.fields['time_zone'].choices = timezone_options
|
||||||
|
|
||||||
@ -126,7 +127,8 @@ def index(request):
|
|||||||
form = None
|
form = None
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = ConfigurationForm(request.POST, prefix='configuration')
|
form = ConfigurationForm(request.POST, initial=status,
|
||||||
|
prefix='configuration')
|
||||||
# pylint: disable-msg=E1101
|
# pylint: disable-msg=E1101
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
_apply_changes(request, status, form.cleaned_data)
|
_apply_changes(request, status, form.cleaned_data)
|
||||||
@ -151,10 +153,7 @@ def get_status():
|
|||||||
def get_current_timezone():
|
def get_current_timezone():
|
||||||
"""Get current timezone"""
|
"""Get current timezone"""
|
||||||
timezone = open('/etc/timezone').read().rstrip()
|
timezone = open('/etc/timezone').read().rstrip()
|
||||||
if timezone != '':
|
return timezone or 'none'
|
||||||
return timezone
|
|
||||||
|
|
||||||
return 'none'
|
|
||||||
|
|
||||||
|
|
||||||
def _apply_changes(request, old_status, new_status):
|
def _apply_changes(request, old_status, new_status):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user