Show holidays in visited countries on trip page

Closes: #112
This commit is contained in:
Edward Betts 2024-01-16 18:08:50 +00:00
parent 4b6f4231b7
commit 44bf744361
2 changed files with 33 additions and 0 deletions

View file

@ -253,6 +253,19 @@ def trip_page(start: str) -> str:
if "geojson_filename" in route:
route["geojson"] = agenda.trip.read_geojson(route.pop("geojson_filename"))
if trip.end:
countries = {c.alpha_2 for c in trip.countries}
holidays = [
hol
for hol in agenda.holidays.get_all(
trip.start, trip.end, app.config["DATA_DIR"]
)
if hol.country.upper() in countries
]
holidays.sort(key=lambda item: (item.date, item.country))
else:
holidays = []
return flask.render_template(
"trip_page.html",
trip=trip,
@ -263,6 +276,7 @@ def trip_page(start: str) -> str:
routes=routes,
get_country=agenda.get_country,
format_list_with_ampersand=format_list_with_ampersand,
holidays=holidays,
)