Commit e84f0aea authored by Xiaowu Zhang's avatar Xiaowu Zhang

Formulator DateTimeField: when timezone should be displayed,regenerate sub form

When want to display timezone in datetimefield, some time timezone
attribute is lost in sub form for the backward compatibility
reason. So to display timezone, a new sub form should be regenerated
parent 4d8f0c33
......@@ -151,6 +151,11 @@ class DateTimeField(ZMIField):
assert 0, "Unknown input_style."
self.on_value_css_class_changed(self.values['css_class'])
def on_value_timezone_style_changed(self, value):
if value:
input_style = self.get_value('input_style')
self.on_value_input_style_changed(input_style)
def on_value_css_class_changed(self, value):
for field in self.sub_form.get_fields():
field.values['css_class'] = value
......
......@@ -118,6 +118,20 @@ class FormTestCase(unittest.TestCase):
self.assertEqual({'int_field': 3}, result)
def test_datetime_timezone_rendering(self):
self.form.manage_addProduct['Formulator']\
.manage_addField('date_time','Test Field','DateTimeField')
field = self.form.date_time
sub_form = field.sub_form
if sub_form.has_field('timezone'):
del sub_form.fields['timezone']
#now timezone is not presented
self.assertFalse(self.form.date_time.sub_form.has_field('timezone'))
field._edit({'timezone_style': 1})
#test if timezone's presented
self.assertTrue(self.form.date_time.sub_form.has_field('timezone'))
def test_datetime_css_class_rendering(self):
# test that a bug is fixed, which causing the css_class value
# not to be rendered
......
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