From d9b1d77872d2bf08039969440f9ed32cfadf3e5b Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 4 Jan 2024 22:55:19 +0000 Subject: [PATCH] Add trips page Creating a new entity called a trip. This will group together any travel accommodation and conferences that happen together on one trip. A trip is assumed to start when leaving home and finish when returning home. The start date of a trip in is the trip ID. The date is written in ISO format. This assumes there cannot be multiple trips one one day. This assumption might be wrong, for example a morning day trip by rail, then another trip starts in the afternoon. I can change my choice of using dates as trip IDs if that happens. Sometimes during the planning of a trip the start date is unknown. For now we make up a start date, we can always change it later. If we use the start date in URLs then the URLs will change. Might need to keep a file of redirects, or could think of a different style of identifier. Trip ID have been added to accommodation, conferences, trains and flights. Later there will be a trips.yaml with notes about each trip. --- templates/macros.html | 96 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 templates/macros.html diff --git a/templates/macros.html b/templates/macros.html new file mode 100644 index 0000000..b279470 --- /dev/null +++ b/templates/macros.html @@ -0,0 +1,96 @@ +{% macro display_datetime(dt) %}{{ dt.strftime("%a, %d, %b %Y %H:%M %z") }}{% endmacro %} +{% macro display_time(dt) %}{{ dt.strftime("%H:%M %z") }}{% endmacro %} + +{% macro conference_row(item, badge) %} + {% set country = get_country(item.country) if item.country else None %} +
{{ item.start.strftime("%a, %d %b %Y") }}
+
{{ item.end.strftime("%a, %d %b") }}
+
+ {% if item.url %} + {{ item.name }} + {% else %} + {{ item.name }} + {% endif %} + {% if item.going and not (item.accommodation_booked or item.travel_booked) %} + + {{ badge }} + + {% endif %} + {% if item.accommodation_booked %} + accommodation + {% endif %} + {% if item.transport_booked %} + transport + {% endif %} +
+
{{ item.topic }}
+
{{ item.location }}
+
+ {% if country %} + {{ country.flag }} {{ country.name }} + {% elif item.online %} + 💻 Online + {% else %} + + country code {{ item.country }} not found + + {% endif %} +
+{% endmacro %} + +{% macro accommodation_row(item, badge) %} + {% set country = get_country(item.country) %} + + {% set nights = (item.to.date() - item.from.date()).days %} +
{{ item.from.strftime("%a, %d %b %Y") }}
+
{{ item.to.strftime("%a, %d %b") }}
+
{% if nights == 1 %}1 night{% else %}{{ nights }} nights{% endif %}
+
{{ item.operator }}
+
{{ item.location }}
+
+ {% if country %} + {{ country.flag }} {{ country.name }} + {% else %} + + country code {{ item.country }} not found + + {% endif %} +
+
+ {% if item.url %} + {{ item.name }} + {% else %} + {{ item.name }} + {% endif %} +
+{% endmacro %} + +{% macro flight_row(item) %} +
{{ item.depart.strftime("%a, %d %b %Y") }}
+
{{ item.from }} → {{ item.to }}
+
{{ item.depart.strftime("%H:%M") }}
+
+ {% if item.arrive %} + {{ item.arrive.strftime("%H:%M") }} + {% if item.arrive.date() != item.depart.date() %}+1 day{% endif %} + {% endif %} +
+
{{ item.duration }}
+
{{ item.airline }}{{ item.flight_number }}
+
{{ item.booking_reference }}
+{% endmacro %} + +{% macro train_row(item) %} +
{{ item.depart.strftime("%a, %d %b %Y") }}
+
{{ item.from }} → {{ item.to }}
+
{{ item.depart.strftime("%H:%M") }}
+
+ {% if item.arrive %} + {{ item.arrive.strftime("%H:%M") }} + {% if item.arrive.date() != item.depart.date() %}+1 day{% endif %} + {% endif %} +
+
{{ ((item.arrive - item.depart).total_seconds() // 60) | int }} mins
+
{{ item.operator }}
+
{{ item.booking_reference }}
+{% endmacro %}