diff --git a/flaskr/borne.py b/flaskr/borne.py index a1abdc5..7b148fd 100644 --- a/flaskr/borne.py +++ b/flaskr/borne.py @@ -20,10 +20,37 @@ @bp.route('/ask', methods=('GET', 'POST')) def ask(): - form = AskForm() + db = get_db() + # result + result = dict() + ## today + sql = """ + SELECT + SUM(cycle_dist) AS nb_km, + COUNT(b.id) AS nb_id + FROM borne b + WHERE DATETIME(cycle_datetime) >= DATETIME('now') + """ + # WHERE DATETIME(cycle_datetime) >= DATETIME('2019-05-14') + result_today = db.execute(sql).fetchone() + result['nb_id_today'] = result_today['nb_id'] + result['nb_km_today'] = result_today['nb_km'] + + ## total + sql = """ + SELECT + SUM(cycle_dist) AS nb_km, + COUNT(b.id) AS nb_id + FROM borne b + """ + result_total = db.execute(sql).fetchone() + result['nb_id_total'] = result_total['nb_id'] + result['nb_km_total'] = result_total['nb_km'] + + # form + form = AskForm() if form.validate_on_submit(): - db = get_db() data = ( form.cycle_time.data, form.cycle_dist.data, @@ -38,7 +65,7 @@ def ask(): flash(_("Thank you!")) return redirect(url_for('borne.ask')) - return render_template('borne/ask.html', form=form) + return render_template('borne/ask.html', form=form, result=result) @bp.route('/show') diff --git a/flaskr/messages.pot b/flaskr/messages.pot index b21395b..bb299f8 100644 --- a/flaskr/messages.pot +++ b/flaskr/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: flaskr 1.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2019-05-08 19:45+0200\n" +"POT-Creation-Date: 2019-05-18 16:11+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,19 +17,19 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.6.0\n" -#: flaskr/borne.py:38 flaskr/borne.py:77 +#: flaskr/borne.py:64 flaskr/borne.py:103 msgid "Thank you!" msgstr "" -#: flaskr/borne.py:67 +#: flaskr/borne.py:93 msgid "Time is required" msgstr "" -#: flaskr/borne.py:69 +#: flaskr/borne.py:95 msgid "Distance is required" msgstr "" -#: flaskr/borne.py:71 +#: flaskr/borne.py:97 msgid "Type is required" msgstr "" @@ -57,6 +57,22 @@ msgstr "" msgid "Submit" msgstr "" +#: flaskr/templates/borne/ask.html:25 +msgid "Today" +msgstr "" + +#: flaskr/templates/borne/ask.html:26 +msgid "Total" +msgstr "" + +#: flaskr/templates/borne/ask.html:32 +msgid "Submissions" +msgstr "" + +#: flaskr/templates/borne/ask.html:37 +msgid "Kilometers" +msgstr "" + #: flaskr/templates/borne/show.html:17 msgid "Date" msgstr "" diff --git a/flaskr/static/style.css b/flaskr/static/style.css index fa16559..1061926 100644 --- a/flaskr/static/style.css +++ b/flaskr/static/style.css @@ -31,6 +31,11 @@ h1, h2, h3, h4, h5, h6 { margin: auto } +.table-smaller { + margin: auto; + max-width: 600px; +} + form { width: 100%; max-width: 330px; diff --git a/flaskr/templates/borne/ask.html b/flaskr/templates/borne/ask.html index 6e4e50a..789238d 100644 --- a/flaskr/templates/borne/ask.html +++ b/flaskr/templates/borne/ask.html @@ -14,4 +14,28 @@

Cyclo-borne

{% block content %} {{ render_form(form) }} + +
+ + + + + + + + + + + + + + + + + + + + + +
{{ _('Today') }}{{ _('Total') }}
{{ _('Submissions') }}{{ result['nb_id_today'] }}{{ result['nb_id_total'] }}
{{ _('Kilometers') }}{{ result['nb_km_today'] }}{{ result['nb_km_total'] }}
{% endblock %} diff --git a/flaskr/translations/fr/LC_MESSAGES/messages.mo b/flaskr/translations/fr/LC_MESSAGES/messages.mo index 86132de..f2f4c90 100644 Binary files a/flaskr/translations/fr/LC_MESSAGES/messages.mo and b/flaskr/translations/fr/LC_MESSAGES/messages.mo differ diff --git a/flaskr/translations/fr/LC_MESSAGES/messages.po b/flaskr/translations/fr/LC_MESSAGES/messages.po index c8ae822..e070dca 100644 --- a/flaskr/translations/fr/LC_MESSAGES/messages.po +++ b/flaskr/translations/fr/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2019-05-08 19:45+0200\n" +"POT-Creation-Date: 2019-05-18 16:11+0200\n" "PO-Revision-Date: 2019-05-05 19:29+0200\n" "Last-Translator: FULL NAME \n" "Language: fr\n" @@ -18,19 +18,19 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.6.0\n" -#: flaskr/borne.py:38 flaskr/borne.py:77 +#: flaskr/borne.py:64 flaskr/borne.py:103 msgid "Thank you!" msgstr "Merci !" -#: flaskr/borne.py:67 +#: flaskr/borne.py:93 msgid "Time is required" msgstr "Le temps est requis" -#: flaskr/borne.py:69 +#: flaskr/borne.py:95 msgid "Distance is required" msgstr "La distance est requise" -#: flaskr/borne.py:71 +#: flaskr/borne.py:97 msgid "Type is required" msgstr "Le type est requis" @@ -58,6 +58,22 @@ msgstr "Type de vélo" msgid "Submit" msgstr "Soumettre" +#: flaskr/templates/borne/ask.html:25 +msgid "Today" +msgstr "Aujourd'hui" + +#: flaskr/templates/borne/ask.html:26 +msgid "Total" +msgstr "Total" + +#: flaskr/templates/borne/ask.html:32 +msgid "Submissions" +msgstr "Enregistrements" + +#: flaskr/templates/borne/ask.html:37 +msgid "Kilometers" +msgstr "Kilomètres" + #: flaskr/templates/borne/show.html:17 msgid "Date" msgstr "Date" @@ -71,9 +87,5 @@ msgid "Distance (km)" msgstr "Distance (km)" #: flaskr/templates/borne/show.html:20 -msgid "Type of bicycle" -msgstr "Type de vélo" - -#~ msgid "Time (HH:MM AM)" -#~ msgstr "Temps (HH:MM AM)" - +msgid "Type of bicycle" +msgstr "Type de vélo"