Add accommodation page

Closes: #88
This commit is contained in:
Edward Betts 2024-01-01 21:26:39 +00:00
parent ac1f279cb4
commit aa7d7b7e6c
6 changed files with 100 additions and 0 deletions

View file

@ -111,5 +111,30 @@ def conference_list() -> str:
)
@app.route("/accommodation")
def accommodation_list() -> str:
"""Page showing a list of past, present and future accommodation."""
data_dir = app.config["PERSONAL_DATA"]
items = agenda.travel.parse_yaml("accommodation", data_dir)
stays_in_2024 = [item for item in items if item["from"].year == 2024]
total_nights_2024 = sum(
(stay["to"].date() - stay["from"].date()).days for stay in stays_in_2024
)
nights_abroad_2024 = sum(
(stay["to"].date() - stay["from"].date()).days
for stay in stays_in_2024
if stay["country"] != "gb"
)
return flask.render_template(
"accommodation.html",
items=items,
total_nights_2024=total_nights_2024,
nights_abroad_2024=nights_abroad_2024,
)
if __name__ == "__main__":
app.run(host="0.0.0.0")