From 291b5459155cba6bc3b75cfb78992824c2a61683 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 8 Apr 2024 09:08:57 +0200 Subject: [PATCH] Split accommodation list: past, current, future Closes: #145 --- templates/accommodation.html | 4 +++- web_view.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/accommodation.html b/templates/accommodation.html index d2df5e6..8109ad8 100644 --- a/templates/accommodation.html +++ b/templates/accommodation.html @@ -42,7 +42,9 @@
- {{ section("Accommodation", items) }} + {{ section("Past", past) }} + {{ section("Current", current) }} + {{ section("Future", future) }}
diff --git a/web_view.py b/web_view.py index e927b49..d34be5d 100755 --- a/web_view.py +++ b/web_view.py @@ -21,7 +21,7 @@ import agenda.error_mail import agenda.holidays import agenda.thespacedevs import agenda.trip -from agenda import format_list_with_ampersand, travel +from agenda import format_list_with_ampersand, travel, uk_tz from agenda.types import StrDict app = flask.Flask(__name__) @@ -206,9 +206,17 @@ def accommodation_list() -> str: if this_trip := trip_lookup.get(key): item["linked_trip"] = this_trip + now = uk_tz.localize(datetime.now()) + + past = [conf for conf in items if conf["to"] < now] + current = [conf for conf in items if conf["from"] <= now and conf["to"] >= now] + future = [conf for conf in items if conf["from"] > now] + return flask.render_template( "accommodation.html", - items=items, + past=past, + current=current, + future=future, total_nights_2024=total_nights_2024, nights_abroad_2024=nights_abroad_2024, get_country=agenda.get_country,