Commit 9668c1a1 authored by Aurel's avatar Aurel

datetime widget : allow definition of a default timezone

Also commit the datetime field used by proxy field with the timezone
properties defined in its sub-form so that proxy field work when
using these new parameters
parent e93da210
......@@ -184,10 +184,6 @@ class DateTimeField(ZMIField):
if REQUEST.form['subfield_%s_%s' % (key, 'year')]:
return None
gmt_timezones = [('GMT%s' %zone, 'GMT%s' %zone,) for zone in range(-12, 0)]\
+ [('GMT', 'GMT',),] \
+ [('GMT+%s' %zone, 'GMT+%s' %zone,) for zone in range(1, 13)]
def create_datetime_text_sub_form():
sub_form = BasicForm()
......@@ -238,7 +234,7 @@ def create_datetime_text_sub_form():
title = "Timezone",
required = 0,
default = 'GMT',
items = gmt_timezones,
items = Widget.gmt_timezones,
size = 1)
sub_form.add_fields([hour, minute, ampm, timezone], "time")
return sub_form
......@@ -296,7 +292,7 @@ def create_datetime_list_sub_form():
title = "Timezone",
required = 0,
default = 'GMT',
items = gmt_timezones,
items = Widget.gmt_timezones,
size = 1)
sub_form.add_group("time")
......
......@@ -1270,6 +1270,10 @@ class MultiCheckBoxWidget(MultiItemsWidget):
MultiCheckBoxWidgetInstance = MultiCheckBoxWidget()
gmt_timezones = [('GMT%s' %zone, 'GMT%s' %zone,) for zone in range(-12, 0)]\
+ [('GMT', 'GMT',),] \
+ [('GMT+%s' %zone, 'GMT+%s' %zone,) for zone in range(1, 13)]
class DateTimeWidget(Widget):
"""
Added support for key in every call to render_sub_field
......@@ -1351,6 +1355,15 @@ class DateTimeWidget(Widget):
("list", "list")],
size=1)
default_timezone = fields.ListField('default_timezone',
title="Default Timezone",
description=(
"The default timezone display when inputing a new date"),
default="GMT",
items=gmt_timezones,
required=1,
size=1)
input_order = fields.ListField('input_order',
title="Input order",
description=(
......@@ -1378,8 +1391,8 @@ class DateTimeWidget(Widget):
property_names = Widget.property_names +\
['default_now', 'date_separator', 'time_separator',
'input_style', 'input_order', 'date_only',
'ampm_time_style', 'timezone_style', 'hide_day',
'hidden_day_is_last_day']
'ampm_time_style', 'timezone_style', 'default_timezone',
'hide_day', 'hidden_day_is_last_day']
def getInputOrder(self, field):
input_order = field.get_value('input_order')
......@@ -1437,7 +1450,7 @@ class DateTimeWidget(Widget):
hour = None
minute = None
ampm = None
timezone = None
timezone = field.get_value("default_timezone")
if isinstance(value, DateTime):
year = "%04d" % value.year()
month = "%02d" % value.month()
......
......@@ -280,6 +280,7 @@ class SerializeTestCase(unittest.TestCase):
request.update(default_values)
request.update( {'field_input_style': 'list',
'field_input_order': 'mdy',
'field_default_timezone': 'GMT',
'field_date_only': '',
'field_css_class': 'test_css',
'field_time_separator': '$',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment