Add holiday page
Page showing holidays in countries of interest, just in English for now.
This commit is contained in:
parent
69e10db8ef
commit
322b65237d
18
templates/holiday_list.html
Normal file
18
templates/holiday_list.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% from "macros.html" import display_date %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container-fluid mt-2">
|
||||||
|
<h1>Holidays</h1>
|
||||||
|
<table class="table table-hover w-auto">
|
||||||
|
{% for item in items %}
|
||||||
|
{% set country = get_country(item.country) %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-end">{{ display_date(item.date) }}</td>
|
||||||
|
<td>{{ country.flag }} {{ country.name }}</td>
|
||||||
|
<td>{{ item.name }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -8,6 +8,7 @@
|
||||||
{"endpoint": "accommodation_list", "label": "Accommodation" },
|
{"endpoint": "accommodation_list", "label": "Accommodation" },
|
||||||
{"endpoint": "gaps_page", "label": "Gaps" },
|
{"endpoint": "gaps_page", "label": "Gaps" },
|
||||||
{"endpoint": "launch_list", "label": "Space launches" },
|
{"endpoint": "launch_list", "label": "Space launches" },
|
||||||
|
{"endpoint": "holiday_list", "label": "Holidays" },
|
||||||
] %}
|
] %}
|
||||||
|
|
||||||
|
|
||||||
|
|
18
web_view.py
18
web_view.py
|
@ -7,7 +7,7 @@ import operator
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
import werkzeug
|
import werkzeug
|
||||||
|
@ -16,6 +16,7 @@ import yaml
|
||||||
|
|
||||||
import agenda.data
|
import agenda.data
|
||||||
import agenda.error_mail
|
import agenda.error_mail
|
||||||
|
import agenda.holidays
|
||||||
import agenda.thespacedevs
|
import agenda.thespacedevs
|
||||||
import agenda.trip
|
import agenda.trip
|
||||||
from agenda import format_list_with_ampersand, travel
|
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__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0")
|
app.run(host="0.0.0.0")
|
||||||
|
|
Loading…
Reference in a new issue