From e799a88faefd5527654bf1408024598479289c98 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 9 Nov 2018 11:36:56 +0100 Subject: [PATCH 3/3] visualization: add truncated previous year range (fixes #27407) It goes from 01/01 to 31/12 of previous year, i.e. if we are the 01/01/2019 it matches 01/01/2018-31/12/2018. --- bijoe/locale/fr/LC_MESSAGES/django.po | 40 +++++++++++++++------------ bijoe/visualization/forms.py | 6 ++++ tests/test_schema1.py | 25 +++++++++++++++++ 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/bijoe/locale/fr/LC_MESSAGES/django.po b/bijoe/locale/fr/LC_MESSAGES/django.po index 779635d..a5451f5 100644 --- a/bijoe/locale/fr/LC_MESSAGES/django.po +++ b/bijoe/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: bijoe 0.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-01-03 11:04+0000\n" +"POT-Creation-Date: 2019-01-14 10:01+0000\n" "PO-Revision-Date: 2018-07-17 21:18+0200\n" "Last-Translator: Benjamin Dauvergne \n" "Language-Team: fr \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: templates/bijoe/base.html:11 templates/bijoe/base.html.py:15 +#: templates/bijoe/base.html:11 templates/bijoe/base.html:15 #: templates/bijoe/warehouse.html:5 views.py:79 msgid "Statistics" msgstr "Statistiques" @@ -26,7 +26,7 @@ msgstr "Statistiques" msgid "Save visualization" msgstr "Enregistrer une visualisation" -#: templates/bijoe/create_visualization.html:19 templates/bijoe/cube.html:65 +#: templates/bijoe/create_visualization.html:19 templates/bijoe/cube.html:67 #: templates/bijoe/visualization.html:23 msgid "Save" msgstr "Enregistrer" @@ -41,15 +41,15 @@ msgstr "Annuler" msgid "Homepage" msgstr "Accueil" -#: templates/bijoe/cube.html:48 +#: templates/bijoe/cube.html:50 msgid "Visualiser" msgstr "Visualiser" -#: templates/bijoe/cube.html:63 templates/bijoe/visualization.html:18 +#: templates/bijoe/cube.html:65 templates/bijoe/visualization.html:18 msgid "URL for IFRAME" msgstr "URL pour IFRAME" -#: templates/bijoe/cube.html:68 +#: templates/bijoe/cube.html:70 msgid "Please choose some measures and groupings." msgstr "Veuillez choisir des mesures et des regroupements." @@ -120,45 +120,51 @@ msgstr "ce trimestre" msgid "last quarter" msgstr "le trimestre précédent" -#: visualization/forms.py:93 +#: visualization/forms.py:82 +msgid "since 1st january last year" +msgstr "depuis le 1er janvier de l'année précédente" + +#: visualization/forms.py:99 msgid "start" msgstr "début" -#: visualization/forms.py:95 +#: visualization/forms.py:101 msgid "end" msgstr "fin" -#: visualization/forms.py:150 +#: visualization/forms.py:156 msgid "Presentation" msgstr "Représentation" -#: visualization/forms.py:151 +#: visualization/forms.py:157 msgid "table" msgstr "tableau" -#: visualization/forms.py:152 +#: visualization/forms.py:158 msgid "chart" msgstr "graphique" -#: visualization/forms.py:164 +#: visualization/forms.py:170 msgid "Loop by" msgstr "Regroupement(s)" -#: visualization/forms.py:185 +#: visualization/forms.py:191 msgid "Group by horizontaly" msgstr "Regroupement horizontal" -#: visualization/forms.py:190 +#: visualization/forms.py:196 msgid "Group by vertically" msgstr "Regroupement vertical" -#: visualization/forms.py:198 +#: visualization/forms.py:204 msgid "Measure" msgstr "Mesure" -#: visualization/forms.py:210 +#: visualization/forms.py:216 msgid "You cannot use the same dimension for looping and grouping" -msgstr "Vous ne pouvez pas utiliser la même dimension pour la répétition et le regroupement." +msgstr "" +"Vous ne pouvez pas utiliser la même dimension pour la répétition et le " +"regroupement." #: visualization/models.py:36 msgid "name" diff --git a/bijoe/visualization/forms.py b/bijoe/visualization/forms.py index dd420cb..1ecb716 100644 --- a/bijoe/visualization/forms.py +++ b/bijoe/visualization/forms.py @@ -77,6 +77,12 @@ DATE_RANGES = [ 'start': u'le dernier trimestre', 'end': u'ce trimestre', }, + { + 'value': 'since_1jan_last_year', + 'label': _('since 1st january last year'), + 'start': u'l\'année dernière', + 'end': u'maintenant', + }, ] diff --git a/tests/test_schema1.py b/tests/test_schema1.py index fba8b68..60c3606 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -28,3 +28,28 @@ def test_simple(schema1, app, admin): ['mois (Date)', 'janvier', u'f\xe9vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', u'ao\xfbt'], ['number of rows', '10', '1', '1', '1', '1', '1', '1', '1'], ] + + +def test_truncated_previous_year_range(schema1, app, admin, freezer): + login(app, admin) + response = app.get('/').follow() + response = response.click('Facts 1') + form = response.form + form.set('representation', 'table') + form.set('measure', 'simple_count') + form.set('drilldown_x', 'date__month') + form.set('drilldown_y', 'date__year') + form.set('filter__date_2', 'since_1jan_last_year') + freezer.move_to('2019-01-01 01:00:00') + response = form.submit('visualize') + assert get_table(response) == [ + ['', 'Total'], + ['Total', '0'] + ] + freezer.move_to('2018-01-01 01:00:00') + response = form.submit('visualize') + assert get_table(response) == [ + ['', 'janvier', u'f\xe9vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', u'ao\xfbt', 'Total'], + ['2017', '10', '1', '1', '1', '1', '1', '1', '1', '17'], + ['Total', '10', '1', '1', '1', '1', '1', '1', '1', '17'], + ] -- 2.20.1