Projet

Général

Profil

0001-dataviz-use-month-short-names-instead-of-number-in-l.patch

Valentin Deniaud, 21 février 2022 17:28

Télécharger (2,9 ko)

Voir les différences:

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(-)
combo/apps/dataviz/models.py
635 635
        min_date, max_date = min(dates), max(dates)
636 636

  
637 637
        date_formats = {
638
            'day': 'd-m-Y',
638
            'day': 'd M Y',
639 639
            # Translators: This indicates week number followed by year, for example it can yield W2-2021.
640 640
            # First "W" is the first letter of the word "week" and should be translated accordingly, second
641 641
            # "W" and "o" are interpreted by Django's date filter and should be left as is. First W is
642 642
            # backslash escaped to prevent it from being interpreted, translators should refer to Django's
643 643
            # documentation in order to know if the new letter resulting of translation should be escaped or not.
644 644
            'week': gettext(r'\WW-o'),
645
            'month': 'm-Y',
645
            'month': 'M Y',
646 646
            'year': 'Y',
647 647
            'weekday': 'l',
648 648
        }
tests/test_dataviz.py
1807 1807

  
1808 1808
    chart = cell.get_chart()
1809 1809
    assert len(chart.x_labels) == 484
1810
    assert chart.x_labels[:3] == ['06-10-2020', '07-10-2020', '08-10-2020']
1811
    assert chart.x_labels[-3:] == ['30-01-2022', '31-01-2022', '01-02-2022']
1810
    assert chart.x_labels[:3] == ['06 Oct 2020', '07 Oct 2020', '08 Oct 2020']
1811
    assert chart.x_labels[-3:] == ['30 Jan 2022', '31 Jan 2022', '01 Feb 2022']
1812 1812
    assert chart.raw_series[0][0][:8] == [0, 0, 0, 0, 0, 0, 0, 1]
1813 1813
    assert chart.raw_series[1][0][:8] == [2, 0, 0, 0, 0, 0, 0, 2]
1814 1814

  
......
1827 1827
    chart = cell.get_chart()
1828 1828
    assert 'time_interval=day' in new_api_mock.call['requests'][1].url
1829 1829
    assert len(chart.x_labels) == 17
1830
    assert chart.x_labels[:3] == ['10-2020', '11-2020', '12-2020']
1831
    assert chart.x_labels[-3:] == ['12-2021', '01-2022', '02-2022']
1830
    assert chart.x_labels[:3] == ['Oct 2020', 'Nov 2020', 'Dec 2020']
1831
    assert chart.x_labels[-3:] == ['Dec 2021', 'Jan 2022', 'Feb 2022']
1832 1832
    assert chart.raw_series == [
1833 1833
        ([1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], {'title': 'Serie 1'}),
1834 1834
        ([4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], {'title': 'Serie 2'}),
1835
-