parent
ac1f279cb4
commit
aa7d7b7e6c
6 changed files with 100 additions and 0 deletions
25
web_view.py
25
web_view.py
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue