visualization: keep None value for dimension cells (#35295)

This commit is contained in:
Benjamin Dauvergne 2019-08-07 16:15:01 +02:00 committed by Frédéric Péters
parent 80332cfc1b
commit c289591dd3
3 changed files with 5 additions and 4 deletions

View File

@ -316,6 +316,7 @@ class EngineCube(object):
'label': cell.label,
'type': cell.type,
'value': value,
'kind': 'dimension' if isinstance(cell, EngineDimension) else 'measure',
} for cell, value in zip(cells, row)]
def build_table_expression(self, joins, table_name, other_conditions=None):

View File

@ -161,9 +161,9 @@ class Visualization(object):
value = s
elif value is not None and cell['type'] == 'bool':
value = _('Yes') if value else _('No')
elif value is None and cell['type'] in ('duration','integer'):
elif value is None and cell['type'] in ('duration', 'integer') and cell['kind'] == 'measure':
value = 0
elif value is None and cell['type'] != 'integer':
elif value is None:
value = _('None')
cell['value'] = value
return data

View File

@ -98,12 +98,12 @@ def test_item_dimension(schema1, app, admin):
response = form.submit('visualize')
assert get_table(response) == [
['Outer SubCategory', u'sub\xe94', u'sub\xe95', u'sub\xe96', u'sub\xe98',
u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91', '0'],
u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91', 'Aucun(e)'],
['number of rows', '0', '0', '0', '0', '0', '0', '0', '1', '15', '1']
]
form.set('filter__outersubcategory', ['__none__'])
response = form.submit('visualize')
assert get_table(response) == [['Outer SubCategory', '0'], ['number of rows', '1']]
assert get_table(response) == [['Outer SubCategory', 'Aucun(e)'], ['number of rows', '1']]
def test_yearmonth_drilldown(schema1, app, admin):