From 4874fbb1900b6422b9ed8895dae8c354a9b21ba0 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 21 Oct 2023 15:44:49 +0100 Subject: [PATCH] Add links to transport or accommodation with a URL Closes #30 --- agenda/__init__.py | 9 ++++++++- agenda/types.py | 1 + templates/index.html | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/agenda/__init__.py b/agenda/__init__.py index 094421c..4d9a4b4 100644 --- a/agenda/__init__.py +++ b/agenda/__init__.py @@ -343,8 +343,14 @@ def get_accommodation(from_date: date, filepath: str) -> list[Event]: date=from_date, name="accommodation", title=f"check-in {title} ({night_str})", + url=item.get("url"), + ) + checkout = Event( + date=to_date, + name="accommodation", + title="check-out " + title, + url=item.get("url"), ) - checkout = Event(date=to_date, name="accommodation", title="check-out " + title) events += [checkin, checkout] return events @@ -356,6 +362,7 @@ def get_travel(from_date: date, method: str, filepath: str) -> list[Event]: date=item["depart"].date(), name="transport", title=f'{method} from {item["from"]} to {item["to"]}', + url=item.get("url"), ) for item in yaml.safe_load(open(filepath)) if item["depart"].date() >= from_date diff --git a/agenda/types.py b/agenda/types.py index 6877b49..026f2ff 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -11,3 +11,4 @@ class Event: name: str date: date title: str | None = None + url: str | None = None diff --git a/templates/index.html b/templates/index.html index a5e8a57..5bdf5e3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -55,8 +55,10 @@ {{event.date.strftime("%a, %d, %b %Y")}} + {% if event.url %}{% endif %} {{ event_labels.get(event.name) or event.name }} {%- if event.title -%}: {{ event.title }}{% endif %} + {% if event.url %}{% endif %} {{ days(event.date) }}