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.
This commit is contained in:
Benjamin Dauvergne 2018-11-09 11:36:56 +01:00
parent 86b169bd6c
commit 8d28b5012c
3 changed files with 54 additions and 17 deletions

View File

@ -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 <bdauvergne@entrouvert.com>\n"
"Language-Team: fr <fr@li.org>\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"

View File

@ -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',
},
]

View File

@ -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'],
]