Add page to generate a list of trips as text

This commit is contained in:
Edward Betts 2024-01-30 10:35:57 +00:00
parent 6c8e1bf48d
commit 8b777e64fc
3 changed files with 110 additions and 0 deletions

View file

@ -220,6 +220,23 @@ def trip_list() -> str:
)
@app.route("/trip/text")
def trip_list_text() -> str:
"""Page showing a list of trips."""
trip_list = agenda.trip.build_trip_list()
today = date.today()
future = [item for item in trip_list if item.start > today]
return flask.render_template(
"trip_list_text.html",
future=future,
today=today,
get_country=agenda.get_country,
format_list_with_ampersand=format_list_with_ampersand,
)
def human_readable_delta(future_date: date) -> str | None:
"""
Calculate the human-readable time delta for a given future date.