From 281eac6b3cf060f5b5ece7421ce1818c98f58cbf Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 7 Aug 2019 16:15:01 +0200 Subject: [PATCH] visualization: keep None value for dimension cells (#35295) --- bijoe/engine.py | 1 + bijoe/visualization/utils.py | 4 ++-- tests/test_schema1.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bijoe/engine.py b/bijoe/engine.py index 9783b8f..1662c13 100644 --- a/bijoe/engine.py +++ b/bijoe/engine.py @@ -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): diff --git a/bijoe/visualization/utils.py b/bijoe/visualization/utils.py index 13d21b5..5ec242f 100644 --- a/bijoe/visualization/utils.py +++ b/bijoe/visualization/utils.py @@ -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 diff --git a/tests/test_schema1.py b/tests/test_schema1.py index 49e62fe..8f6b639 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -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): -- 2.22.0