ods: don't consider numbers starting with 0 or + for number columns (#18729)
This commit is contained in:
parent
7bf255d09a
commit
1bdb9d6e11
|
@ -802,6 +802,7 @@ def test_backoffice_ods(pub):
|
|||
formdef.fields.append(fields.FileField(id='4', label='file field', type='file'))
|
||||
formdef.fields.append(fields.DateField(id='5', label='date field', type='date'))
|
||||
formdef.fields.append(fields.StringField(id='6', label='number field', type='string'))
|
||||
formdef.fields.append(fields.StringField(id='7', label='phone field', type='string'))
|
||||
formdef.store()
|
||||
|
||||
formdata = formdef.data_class().select(lambda x: x.status == 'wf-new')[0]
|
||||
|
@ -809,6 +810,7 @@ def test_backoffice_ods(pub):
|
|||
formdata.data['4'].receive(['hello world'])
|
||||
formdata.data['5'] = time.strptime('2015-05-12', '%Y-%m-%d')
|
||||
formdata.data['6'] = '12345'
|
||||
formdata.data['7'] = '0102030405'
|
||||
formdata.store()
|
||||
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
|
@ -829,6 +831,7 @@ def test_backoffice_ods(pub):
|
|||
created_column = all_texts.index('Created')
|
||||
date_column = all_texts.index('date field')
|
||||
number_column = all_texts.index('number field')
|
||||
phone_column = all_texts.index('phone field')
|
||||
|
||||
for row in ods_sheet.findall('.//{%s}table-row' % ods.TABLE_NS):
|
||||
if row.findall('.//{%s}table-cell/{%s}p' % (
|
||||
|
@ -849,6 +852,8 @@ def test_backoffice_ods(pub):
|
|||
'{%s}value-type' % ods.OFFICE_NS] == 'float'
|
||||
assert row.findall('.//{%s}table-cell' % ods.TABLE_NS)[number_column].attrib[
|
||||
'{%s}value' % ods.OFFICE_NS] == '12345'
|
||||
assert row.findall('.//{%s}table-cell' % ods.TABLE_NS)[phone_column].attrib[
|
||||
'{%s}value-type' % ods.OFFICE_NS] == 'string'
|
||||
|
||||
def test_backoffice_statistics(pub):
|
||||
create_superuser(pub)
|
||||
|
|
|
@ -33,6 +33,8 @@ XLINK_NS = 'http://www.w3.org/1999/xlink'
|
|||
|
||||
|
||||
def is_number(value):
|
||||
if value and (value.startswith('0') or value.startswith('+')):
|
||||
return False
|
||||
try:
|
||||
float(value)
|
||||
except ValueError:
|
||||
|
|
Loading…
Reference in New Issue