From ed1114292227e8798dae63815598e734679aca2d Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Mon, 21 Feb 2022 16:26:13 +0100 Subject: [PATCH] dataviz: use month short names instead of number in labels (#60738) --- combo/apps/dataviz/models.py | 4 ++-- tests/test_dataviz.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/combo/apps/dataviz/models.py b/combo/apps/dataviz/models.py index 5b8ac989..8750c4b1 100644 --- a/combo/apps/dataviz/models.py +++ b/combo/apps/dataviz/models.py @@ -635,14 +635,14 @@ class ChartNgCell(CellBase): min_date, max_date = min(dates), max(dates) date_formats = { - 'day': 'd-m-Y', + 'day': 'd M Y', # Translators: This indicates week number followed by year, for example it can yield W2-2021. # First "W" is the first letter of the word "week" and should be translated accordingly, second # "W" and "o" are interpreted by Django's date filter and should be left as is. First W is # backslash escaped to prevent it from being interpreted, translators should refer to Django's # documentation in order to know if the new letter resulting of translation should be escaped or not. 'week': gettext(r'\WW-o'), - 'month': 'm-Y', + 'month': 'M Y', 'year': 'Y', 'weekday': 'l', } diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 578c659b..d07470ea 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -1807,8 +1807,8 @@ def test_chartng_cell_new_api_aggregation(new_api_statistics, app, admin_user, n chart = cell.get_chart() assert len(chart.x_labels) == 484 - assert chart.x_labels[:3] == ['06-10-2020', '07-10-2020', '08-10-2020'] - assert chart.x_labels[-3:] == ['30-01-2022', '31-01-2022', '01-02-2022'] + assert chart.x_labels[:3] == ['06 Oct 2020', '07 Oct 2020', '08 Oct 2020'] + assert chart.x_labels[-3:] == ['30 Jan 2022', '31 Jan 2022', '01 Feb 2022'] assert chart.raw_series[0][0][:8] == [0, 0, 0, 0, 0, 0, 0, 1] assert chart.raw_series[1][0][:8] == [2, 0, 0, 0, 0, 0, 0, 2] @@ -1827,8 +1827,8 @@ def test_chartng_cell_new_api_aggregation(new_api_statistics, app, admin_user, n chart = cell.get_chart() assert 'time_interval=day' in new_api_mock.call['requests'][1].url assert len(chart.x_labels) == 17 - assert chart.x_labels[:3] == ['10-2020', '11-2020', '12-2020'] - assert chart.x_labels[-3:] == ['12-2021', '01-2022', '02-2022'] + assert chart.x_labels[:3] == ['Oct 2020', 'Nov 2020', 'Dec 2020'] + assert chart.x_labels[-3:] == ['Dec 2021', 'Jan 2022', 'Feb 2022'] assert chart.raw_series == [ ([1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], {'title': 'Serie 1'}), ([4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], {'title': 'Serie 2'}), -- 2.30.2