Split accommodation list: past, current, future

Closes: #145
This commit is contained in:
Edward Betts 2024-04-08 09:08:57 +02:00
parent 37be85593b
commit 291b545915
2 changed files with 13 additions and 3 deletions

View file

@ -42,7 +42,9 @@
</ul>
<div class="grid-container">
{{ section("Accommodation", items) }}
{{ section("Past", past) }}
{{ section("Current", current) }}
{{ section("Future", future) }}
</div>
</div>

View file

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