Add holiday page

Page showing holidays in countries of interest, just in English for now.
This commit is contained in:
Edward Betts 2024-01-16 12:06:46 +00:00
parent 69e10db8ef
commit 322b65237d
3 changed files with 36 additions and 1 deletions

View file

@ -7,7 +7,7 @@ import operator
import os.path
import sys
import traceback
from datetime import date, datetime
from datetime import date, datetime, timedelta
import flask
import werkzeug
@ -16,6 +16,7 @@ import yaml
import agenda.data
import agenda.error_mail
import agenda.holidays
import agenda.thespacedevs
import agenda.trip
from agenda import format_list_with_ampersand, travel
@ -246,5 +247,20 @@ def trip_page(start: str) -> str:
)
@app.route("/holidays")
def holiday_list() -> str:
"""List of holidays."""
today = date.today()
data_dir = app.config["DATA_DIR"]
next_year = today + timedelta(days=1 * 365)
items = agenda.holidays.get_all(today - timedelta(days=2), next_year, data_dir)
items.sort(key=lambda item: (item.date, item.country))
return flask.render_template(
"holiday_list.html", items=items, get_country=agenda.get_country
)
if __name__ == "__main__":
app.run(host="0.0.0.0")