Commit 1875022b authored by Jérome Perrin's avatar Jérome Perrin

The previous commit introduced a problem, float fields were no longer able to

display non float values.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15258 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 33d91234
......@@ -1059,10 +1059,11 @@ class FloatWidget(TextWidget):
if input_style.find('%')>=0:
percent=1
value = float(value) * 100
if precision:
value = round(value, precision)
try :
value = str(float(value))
float_value = float(value)
if precision:
float_value = round(float_value, precision)
value = str(float_value)
except ValueError:
return value
else:
......
......@@ -67,6 +67,12 @@ class TestFloatField(unittest.TestCase):
self.field.values['editable'] = 0
self.assertEquals('1 000.00', self.field.render(1000))
def test_render_string_value(self):
self.field.values['precision'] = 2
self.field.values['editable'] = 0
self.assertEquals('12.34', self.field.render("12.34"))
self.assertEquals('not float', self.field.render("not float"))
def test_render_big_numbers(self):
self.field.values['precision'] = 2
self.field.values['editable'] = 0
......
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