Projet

Général

Profil

0001-visualization-keep-None-value-for-dimension-cells-35.patch

Benjamin Dauvergne, 07 août 2019 16:16

Télécharger (2,65 ko)

Voir les différences:

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(-)
bijoe/engine.py
316 316
                    'label': cell.label,
317 317
                    'type': cell.type,
318 318
                    'value': value,
319
                    'kind': 'dimension' if isinstance(cell, EngineDimension) else 'measure',
319 320
                } for cell, value in zip(cells, row)]
320 321

  
321 322
    def build_table_expression(self, joins, table_name, other_conditions=None):
bijoe/visualization/utils.py
161 161
                    value = s
162 162
                elif value is not None and cell['type'] == 'bool':
163 163
                    value = _('Yes') if value else _('No')
164
                elif value is None and cell['type'] in ('duration','integer'):
164
                elif value is None and cell['type'] in ('duration', 'integer') and cell['kind'] == 'measure':
165 165
                    value = 0
166
                elif value is None and cell['type'] != 'integer':
166
                elif value is None:
167 167
                    value = _('None')
168 168
                cell['value'] = value
169 169
        return data
tests/test_schema1.py
98 98
    response = form.submit('visualize')
99 99
    assert get_table(response) == [
100 100
        ['Outer SubCategory', u'sub\xe94', u'sub\xe95', u'sub\xe96', u'sub\xe98',
101
         u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91', '0'],
101
         u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91', 'Aucun(e)'],
102 102
        ['number of rows', '0', '0', '0', '0', '0', '0', '0', '1', '15', '1']
103 103
    ]
104 104
    form.set('filter__outersubcategory', ['__none__'])
105 105
    response = form.submit('visualize')
106
    assert get_table(response) == [['Outer SubCategory', '0'], ['number of rows', '1']]
106
    assert get_table(response) == [['Outer SubCategory', 'Aucun(e)'], ['number of rows', '1']]
107 107

  
108 108

  
109 109
def test_yearmonth_drilldown(schema1, app, admin):
110
-