diff --git a/templates/holiday_list.html b/templates/holiday_list.html new file mode 100644 index 0000000..742dd60 --- /dev/null +++ b/templates/holiday_list.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} +{% from "macros.html" import display_date %} + +{% block content %} +
+

Holidays

+ + {% for item in items %} + {% set country = get_country(item.country) %} + + + + + + {% endfor %} +
{{ display_date(item.date) }}{{ country.flag }} {{ country.name }}{{ item.name }}
+
+{% endblock %} diff --git a/templates/navbar.html b/templates/navbar.html index 198b666..9f8085c 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -8,6 +8,7 @@ {"endpoint": "accommodation_list", "label": "Accommodation" }, {"endpoint": "gaps_page", "label": "Gaps" }, {"endpoint": "launch_list", "label": "Space launches" }, + {"endpoint": "holiday_list", "label": "Holidays" }, ] %} diff --git a/web_view.py b/web_view.py index fa0594c..6c21472 100755 --- a/web_view.py +++ b/web_view.py @@ -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")