Add links to transport or accommodation with a URL

Closes #30
This commit is contained in:
Edward Betts 2023-10-21 15:44:49 +01:00
parent 94c4f47018
commit 4874fbb190
3 changed files with 11 additions and 1 deletions

View file

@ -343,8 +343,14 @@ def get_accommodation(from_date: date, filepath: str) -> list[Event]:
date=from_date, date=from_date,
name="accommodation", name="accommodation",
title=f"check-in {title} ({night_str})", 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] events += [checkin, checkout]
return events return events
@ -356,6 +362,7 @@ def get_travel(from_date: date, method: str, filepath: str) -> list[Event]:
date=item["depart"].date(), date=item["depart"].date(),
name="transport", name="transport",
title=f'{method} from {item["from"]} to {item["to"]}', title=f'{method} from {item["from"]} to {item["to"]}',
url=item.get("url"),
) )
for item in yaml.safe_load(open(filepath)) for item in yaml.safe_load(open(filepath))
if item["depart"].date() >= from_date if item["depart"].date() >= from_date

View file

@ -11,3 +11,4 @@ class Event:
name: str name: str
date: date date: date
title: str | None = None title: str | None = None
url: str | None = None

View file

@ -55,8 +55,10 @@
{{event.date.strftime("%a, %d, %b %Y")}} {{event.date.strftime("%a, %d, %b %Y")}}
</td> </td>
<td class="text-start {% if event.name in class_map %} {{ class_map[event.name]}}{% endif %}"> <td class="text-start {% if event.name in class_map %} {{ class_map[event.name]}}{% endif %}">
{% if event.url %}<a href="{{ event.url }}">{% endif %}
{{ event_labels.get(event.name) or event.name }} {{ event_labels.get(event.name) or event.name }}
{%- if event.title -%}: {{ event.title }}{% endif %} {%- if event.title -%}: {{ event.title }}{% endif %}
{% if event.url %}</a>{% endif %}
</td> </td>
<td class="text-end"> <td class="text-end">
{{ days(event.date) }} {{ days(event.date) }}