From 814198ac0c3f753e07ec9ae74f761cad995eb6ee Mon Sep 17 00:00:00 2001 From: merlin Date: Wed, 1 Jan 2025 16:56:14 -0500 Subject: [PATCH] ess using filters for fractions and stuff --- freezing/web/templates/index.html | 47 ++++++++----------------------- freezing/web/views/general.py | 5 ++++ 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/freezing/web/templates/index.html b/freezing/web/templates/index.html index 0b0d601d..4ebe7d57 100644 --- a/freezing/web/templates/index.html +++ b/freezing/web/templates/index.html @@ -144,15 +144,10 @@

@@ -161,15 +156,15 @@

- {{ total_rides|groupnum }} rides + {{ total_rides|groupnum }} ride{{ total_rides|ess }}
- {{ total_hours|groupnum }} hours + {{ total_hours|groupnum }} hour{{ total_hours|ess }}
- {{ total_miles|groupnum }} miles + {{ total_miles|groupnum }} mile{{ total_miles|ess }}
@@ -179,20 +174,15 @@

- {{ today_riders }} - {% if today_riders != 1 %} - riders - {% else %} - rider - {% endif %} + {{ today_riders }} rider{{ today_riders|ess }}
- {{ today_hours|groupnum }} hours + {{ today_hours|groupnum }} hour{{ today_hours|ess }}
- {{ today_miles|groupnum }} miles + {{ today_miles|groupnum }} mile{{ today_miles|ess }}
@@ -206,12 +196,7 @@

- {% if sub_freezing_hours == 1 %} - hour - {% else %} - hours - {% endif %} - below freezing + hour{{ sub_freezing_hours|ess }} below freezing
@@ -222,12 +207,7 @@

- {% if rain_hours == 1 %} - hour - {% else %} - hours - {% endif %} - in the rain + hour{{ rain_hours|ess }} in the rain
@@ -237,13 +217,8 @@

{{ snow_hours|groupnum }}

- {% if snow_hours == 1 %} - hour - {% else %} - hours - {% endif %}
- in the snow + hour{{ snow_hours|ess }} in the snow
diff --git a/freezing/web/views/general.py b/freezing/web/views/general.py index 6f73483b..315ef5f4 100644 --- a/freezing/web/views/general.py +++ b/freezing/web/views/general.py @@ -69,6 +69,11 @@ def groupnum(number): return s + ",".join(reversed(groups)) +@app.template_filter("ess") +def ess(number): + return "" if groupnum(number) == "1" else "s" + + @blueprint.route("/") def index(): q = text("""select count(*) as num_contestants from lbd_athletes""")