From 8d638551046c2b8aaf7579b712a6ef6688a28a94 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 6 Feb 2023 20:23:16 +0100 Subject: add tracks per time period on home page --- fietsboek/__init__.py | 1 + fietsboek/locale/de/LC_MESSAGES/messages.mo | Bin 11757 -> 11855 bytes fietsboek/locale/de/LC_MESSAGES/messages.po | 76 ++++++++++++++------------ fietsboek/locale/en/LC_MESSAGES/messages.mo | Bin 11069 -> 11163 bytes fietsboek/locale/en/LC_MESSAGES/messages.po | 76 ++++++++++++++------------ fietsboek/locale/fietslog.pot | 80 +++++++++++++++------------- fietsboek/summaries.py | 9 ++++ fietsboek/templates/home.jinja2 | 22 ++++++-- 8 files changed, 153 insertions(+), 111 deletions(-) diff --git a/fietsboek/__init__.py b/fietsboek/__init__.py index 9112576..5ca5a4b 100644 --- a/fietsboek/__init__.py +++ b/fietsboek/__init__.py @@ -90,6 +90,7 @@ def maintenance_mode( def main(_global_config, **settings): """This function returns a Pyramid WSGI application.""" parsed_config = mod_config.parse(settings) + settings["jinja2.newstyle"] = True def data_manager(request): return DataManager(Path(request.config.data_dir)) diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.mo b/fietsboek/locale/de/LC_MESSAGES/messages.mo index 7092994..75b0abe 100644 Binary files a/fietsboek/locale/de/LC_MESSAGES/messages.mo and b/fietsboek/locale/de/LC_MESSAGES/messages.mo differ diff --git a/fietsboek/locale/de/LC_MESSAGES/messages.po b/fietsboek/locale/de/LC_MESSAGES/messages.po index dfa2bed..8f6d9f2 100644 --- a/fietsboek/locale/de/LC_MESSAGES/messages.po +++ b/fietsboek/locale/de/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: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-06 19:52+0100\n" "PO-Revision-Date: 2022-07-02 17:35+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -18,39 +18,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "Passwörter stimmen nicht überein" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "Passwort zu kurz" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:545 msgid "tooltip.table.length" msgstr "Länge" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:546 msgid "tooltip.table.uphill" msgstr "Bergauf" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:547 msgid "tooltip.table.downhill" msgstr "Bergab" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:548 msgid "tooltip.table.moving_time" msgstr "Fahrzeit" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:549 msgid "tooltip.table.stopped_time" msgstr "Haltezeit" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:551 msgid "tooltip.table.max_speed" msgstr "Maximalgeschwindigkeit" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:555 msgid "tooltip.table.avg_speed" msgstr "Durchschnittsgeschwindigkeit" @@ -456,51 +456,57 @@ msgstr "Abbrechen" msgid "page.home.title" msgstr "Startseite" -#: fietsboek/templates/home.jinja2:23 +#: fietsboek/templates/home.jinja2:12 +msgid "page.home.summary.track" +msgid_plural "page.home.summary.tracks" +msgstr[0] "%(num)d Strecke" +msgstr[1] "%(num)d Strecken" + +#: fietsboek/templates/home.jinja2:37 msgid "page.home.total" msgstr "Gesamt" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:39 msgid "page.navbar.toggle" msgstr "Navigation umschalten" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.home" msgstr "Startseite" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:53 msgid "page.navbar.browse" msgstr "Stöbern" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:57 msgid "page.navbar.upload" msgstr "Hochladen" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:66 msgid "page.navbar.user" msgstr "Nutzer" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.welcome_user" msgstr "Willkommen, {}!" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.logout" msgstr "Abmelden" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:76 msgid "page.navbar.profile" msgstr "Profil" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:80 msgid "page.navbar.admin" msgstr "Admin" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:86 msgid "page.navbar.login" msgstr "Anmelden" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:90 msgid "page.navbar.create_account" msgstr "Konto Erstellen" @@ -649,15 +655,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "Ein Bestätigungslink wurde versandt" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "Wappen hinzugefügt" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "Wappen bearbeitet" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "Wappen gelöscht" @@ -705,43 +711,43 @@ msgstr "E-Mail-Adresse bestätigt" msgid "flash.password_updated" msgstr "Passwort aktualisiert" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "Strecke gelöscht" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "Persönliche Daten wurden gespeichert" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "Das angegebene Konto wurde nicht gefunden" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "Dieser Freund existiert bereits" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "Freund hinzugefügt" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "Freundschaftsanfrage gesendet" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "Keine Datei ausgewählt" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "Ungültige GPX-Datei gesendet" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:181 msgid "flash.upload_success" msgstr "Hochladen erfolgreich" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:197 msgid "flash.upload_cancelled" msgstr "Hochladen abgebrochen" diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.mo b/fietsboek/locale/en/LC_MESSAGES/messages.mo index 7827a62..7a7d215 100644 Binary files a/fietsboek/locale/en/LC_MESSAGES/messages.mo and b/fietsboek/locale/en/LC_MESSAGES/messages.mo differ diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.po b/fietsboek/locale/en/LC_MESSAGES/messages.po index f4b0239..c1f17a8 100644 --- a/fietsboek/locale/en/LC_MESSAGES/messages.po +++ b/fietsboek/locale/en/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: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-06 19:52+0100\n" "PO-Revision-Date: 2022-06-28 13:11+0200\n" "Last-Translator: \n" "Language: en\n" @@ -18,39 +18,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "Passwords don't match" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "Password not long enough" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:545 msgid "tooltip.table.length" msgstr "Length" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:546 msgid "tooltip.table.uphill" msgstr "Uphill" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:547 msgid "tooltip.table.downhill" msgstr "Downhill" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:548 msgid "tooltip.table.moving_time" msgstr "Moving Time" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:549 msgid "tooltip.table.stopped_time" msgstr "Stopped Time" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:551 msgid "tooltip.table.max_speed" msgstr "Max Speed" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:555 msgid "tooltip.table.avg_speed" msgstr "Average Speed" @@ -452,51 +452,57 @@ msgstr "Cancel" msgid "page.home.title" msgstr "Home" -#: fietsboek/templates/home.jinja2:23 +#: fietsboek/templates/home.jinja2:12 +msgid "page.home.summary.track" +msgid_plural "page.home.summary.tracks" +msgstr[0] "%(num)d track" +msgstr[1] "%(num)d tracks" + +#: fietsboek/templates/home.jinja2:37 msgid "page.home.total" msgstr "Total" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:39 msgid "page.navbar.toggle" msgstr "Toggle navigation" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.home" msgstr "Home" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:53 msgid "page.navbar.browse" msgstr "Browse" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:57 msgid "page.navbar.upload" msgstr "Upload" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:66 msgid "page.navbar.user" msgstr "User" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.welcome_user" msgstr "Welcome, {}!" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.logout" msgstr "Logout" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:76 msgid "page.navbar.profile" msgstr "Profile" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:80 msgid "page.navbar.admin" msgstr "Admin" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:86 msgid "page.navbar.login" msgstr "Login" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:90 msgid "page.navbar.create_account" msgstr "Create Account" @@ -645,15 +651,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "A confirmation link has been sent" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "Badge has been added" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "Badge has been modified" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "Badge has been deleted" @@ -700,43 +706,43 @@ msgstr "Your email address has been verified" msgid "flash.password_updated" msgstr "Password has been updated" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "Track has been deleted" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "Personal data has been updated" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "The friend was not found" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "Friend already exists" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "Friend has been added" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "Friend request sent" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "No file selected" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "Invalid GPX file selected" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:181 msgid "flash.upload_success" msgstr "Upload successful" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:197 msgid "flash.upload_cancelled" msgstr "Upload cancelled" diff --git a/fietsboek/locale/fietslog.pot b/fietsboek/locale/fietslog.pot index a86c43b..f4e3d01 100644 --- a/fietsboek/locale/fietslog.pot +++ b/fietsboek/locale/fietslog.pot @@ -1,14 +1,14 @@ # Translations template for PROJECT. -# Copyright (C) 2022 ORGANIZATION +# Copyright (C) 2023 ORGANIZATION # This file is distributed under the same license as the PROJECT project. -# FIRST AUTHOR , 2022. +# FIRST AUTHOR , 2023. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-12-10 17:37+0100\n" +"POT-Creation-Date: 2023-02-06 19:52+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,39 +17,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.11.0\n" -#: fietsboek/util.py:274 +#: fietsboek/util.py:273 msgid "password_constraint.mismatch" msgstr "" -#: fietsboek/util.py:276 +#: fietsboek/util.py:275 msgid "password_constraint.length" msgstr "" -#: fietsboek/models/track.py:543 +#: fietsboek/models/track.py:545 msgid "tooltip.table.length" msgstr "" -#: fietsboek/models/track.py:544 +#: fietsboek/models/track.py:546 msgid "tooltip.table.uphill" msgstr "" -#: fietsboek/models/track.py:545 +#: fietsboek/models/track.py:547 msgid "tooltip.table.downhill" msgstr "" -#: fietsboek/models/track.py:546 +#: fietsboek/models/track.py:548 msgid "tooltip.table.moving_time" msgstr "" -#: fietsboek/models/track.py:547 +#: fietsboek/models/track.py:549 msgid "tooltip.table.stopped_time" msgstr "" -#: fietsboek/models/track.py:549 +#: fietsboek/models/track.py:551 msgid "tooltip.table.max_speed" msgstr "" -#: fietsboek/models/track.py:553 +#: fietsboek/models/track.py:555 msgid "tooltip.table.avg_speed" msgstr "" @@ -449,51 +449,57 @@ msgstr "" msgid "page.home.title" msgstr "" -#: fietsboek/templates/home.jinja2:23 +#: fietsboek/templates/home.jinja2:12 +msgid "page.home.summary.track" +msgid_plural "page.home.summary.tracks" +msgstr[0] "" +msgstr[1] "" + +#: fietsboek/templates/home.jinja2:37 msgid "page.home.total" msgstr "" -#: fietsboek/templates/layout.jinja2:35 +#: fietsboek/templates/layout.jinja2:39 msgid "page.navbar.toggle" msgstr "" -#: fietsboek/templates/layout.jinja2:46 +#: fietsboek/templates/layout.jinja2:50 msgid "page.navbar.home" msgstr "" -#: fietsboek/templates/layout.jinja2:49 +#: fietsboek/templates/layout.jinja2:53 msgid "page.navbar.browse" msgstr "" -#: fietsboek/templates/layout.jinja2:53 +#: fietsboek/templates/layout.jinja2:57 msgid "page.navbar.upload" msgstr "" -#: fietsboek/templates/layout.jinja2:62 +#: fietsboek/templates/layout.jinja2:66 msgid "page.navbar.user" msgstr "" -#: fietsboek/templates/layout.jinja2:66 +#: fietsboek/templates/layout.jinja2:70 msgid "page.navbar.welcome_user" msgstr "" -#: fietsboek/templates/layout.jinja2:69 +#: fietsboek/templates/layout.jinja2:73 msgid "page.navbar.logout" msgstr "" -#: fietsboek/templates/layout.jinja2:72 +#: fietsboek/templates/layout.jinja2:76 msgid "page.navbar.profile" msgstr "" -#: fietsboek/templates/layout.jinja2:76 +#: fietsboek/templates/layout.jinja2:80 msgid "page.navbar.admin" msgstr "" -#: fietsboek/templates/layout.jinja2:82 +#: fietsboek/templates/layout.jinja2:86 msgid "page.navbar.login" msgstr "" -#: fietsboek/templates/layout.jinja2:86 +#: fietsboek/templates/layout.jinja2:90 msgid "page.navbar.create_account" msgstr "" @@ -637,15 +643,15 @@ msgstr "" msgid "flash.a_confirmation_link_has_been_sent" msgstr "" -#: fietsboek/views/admin.py:49 +#: fietsboek/views/admin.py:48 msgid "flash.badge_added" msgstr "" -#: fietsboek/views/admin.py:73 +#: fietsboek/views/admin.py:72 msgid "flash.badge_modified" msgstr "" -#: fietsboek/views/admin.py:93 +#: fietsboek/views/admin.py:92 msgid "flash.badge_deleted" msgstr "" @@ -689,43 +695,43 @@ msgstr "" msgid "flash.password_updated" msgstr "" -#: fietsboek/views/detail.py:101 +#: fietsboek/views/detail.py:140 msgid "flash.track_deleted" msgstr "" -#: fietsboek/views/profile.py:61 +#: fietsboek/views/profile.py:60 msgid "flash.personal_data_updated" msgstr "" -#: fietsboek/views/profile.py:79 +#: fietsboek/views/profile.py:78 msgid "flash.friend_not_found" msgstr "" -#: fietsboek/views/profile.py:85 +#: fietsboek/views/profile.py:84 msgid "flash.friend_already_exists" msgstr "" -#: fietsboek/views/profile.py:93 +#: fietsboek/views/profile.py:92 msgid "flash.friend_added" msgstr "" -#: fietsboek/views/profile.py:103 +#: fietsboek/views/profile.py:102 msgid "flash.friend_request_sent" msgstr "" -#: fietsboek/views/upload.py:56 +#: fietsboek/views/upload.py:52 msgid "flash.no_file_selected" msgstr "" -#: fietsboek/views/upload.py:66 +#: fietsboek/views/upload.py:62 msgid "flash.invalid_file" msgstr "" -#: fietsboek/views/upload.py:189 +#: fietsboek/views/upload.py:181 msgid "flash.upload_success" msgstr "" -#: fietsboek/views/upload.py:205 +#: fietsboek/views/upload.py:197 msgid "flash.upload_cancelled" msgstr "" diff --git a/fietsboek/summaries.py b/fietsboek/summaries.py index 670c8f2..ed4b197 100644 --- a/fietsboek/summaries.py +++ b/fietsboek/summaries.py @@ -19,6 +19,9 @@ class Summary: items.sort(key=lambda y: y.year) return iter(items) + def __len__(self) -> int: + return len(self.all_tracks()) + def all_tracks(self) -> List[TrackWithMetadata]: """Returns all tracks of the summary. @@ -62,6 +65,9 @@ class YearSummary: items.sort(key=lambda x: x.month) return iter(items) + def __len__(self) -> int: + return len(self.all_tracks()) + def all_tracks(self) -> List[TrackWithMetadata]: """Returns all tracks of the summary. @@ -104,6 +110,9 @@ class MonthSummary: items.sort(key=lambda t: t.date) return iter(items) + def __len__(self) -> int: + return len(self.all_tracks()) + def all_tracks(self) -> List[TrackWithMetadata]: """Returns all tracks of the summary. diff --git a/fietsboek/templates/home.jinja2 b/fietsboek/templates/home.jinja2 index 4a9c3ad..5e552e4 100644 --- a/fietsboek/templates/home.jinja2 +++ b/fietsboek/templates/home.jinja2 @@ -6,13 +6,27 @@ {% if summary %}
{% for year in summary %} - {{ year.year }} — {{ (year.total_length / 1000) | round(2) | format_decimal }} km + + + {{ year.year }} + {{ ngettext("page.home.summary.track", "page.home.summary.tracks", year|length) }} — {{ (year.total_length / 1000) | round(2) | format_decimal }} km +

- {{ _("page.home.total") }}: {{ (summary.total_length / 1000) | round(2) | format_decimal }} km + {{ _("page.home.total") }}: {{ ngettext("page.home.summary.track", "page.home.summary.tracks", summary|length) }}, {{ (summary.total_length / 1000) | round(2) | format_decimal }} km

{% elif home_content %} {{ home_content | safe }} -- cgit v1.2.3