[Erp5-report] r28662 - in /erp5/trunk/products: ERP5Form/tests/ Formulator/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 27 16:18:33 CEST 2009
Author: jerome
Date: Thu Aug 27 16:18:33 2009
New Revision: 28662
URL: http://svn.erp5.org?rev=28662&view=rev
Log:
'format' in render_dict does not have to be based on input_style, as it's only used to represent precision.
Modified:
erp5/trunk/products/ERP5Form/tests/testFields.py
erp5/trunk/products/Formulator/Widget.py
Modified: erp5/trunk/products/ERP5Form/tests/testFields.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testFields.py?rev=28662&r1=28661&r2=28662&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testFields.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/tests/testFields.py [utf8] Thu Aug 27 16:18:33 2009
@@ -140,6 +140,14 @@
self.field.values['precision'] = 2
self.field.values['editable'] = 0
self.assertEquals('1 000.00', self.field.render(1000))
+
+ def test_render_dict(self):
+ self.field.values['input_style'] = '-1 234.5'
+ self.field.values['precision'] = 4
+ self.assertEquals(dict(query=0.12345,
+ format='0.0000',
+ type='float'),
+ self.field.render_dict(0.12345))
def test_render_string_value(self):
self.field.values['precision'] = 2
Modified: erp5/trunk/products/Formulator/Widget.py
URL: http://svn.erp5.org/erp5/trunk/products/Formulator/Widget.py?rev=28662&r1=28661&r2=28662&view=diff
==============================================================================
--- erp5/trunk/products/Formulator/Widget.py [utf8] (original)
+++ erp5/trunk/products/Formulator/Widget.py [utf8] Thu Aug 27 16:18:33 2009
@@ -1417,17 +1417,19 @@
format of provided value.
query : Passthrough of given value.
"""
- input_style = field.get_value('input_style')
precision = field.get_value('precision')
- if precision not in (None, '') and precision != 0:
- for x in xrange(1, precision):
- input_style += '5'
- else:
- input_style = input_style.split('.')[0]
+ format = '0'
+ if precision:
+ format = '0.'
+ # in 'format', the only important thing is the number of decimal places,
+ # so we add some places until we reach the precision defined on the
+ # field.
+ for x in xrange(0, precision):
+ format += '0'
if isinstance(value, unicode):
value = value.encode(field.get_form_encoding())
return {'query': value,
- 'format': input_style,
+ 'format': format,
'type': 'float'}
FloatWidgetInstance = FloatWidget()
More information about the Erp5-report
mailing list