diff --git a/agenda/trip.py b/agenda/trip.py
index 64754c0..f2c4a47 100644
--- a/agenda/trip.py
+++ b/agenda/trip.py
@@ -65,12 +65,11 @@ def depart_datetime(item: StrDict) -> datetime:
return datetime.combine(depart, time.min).replace(tzinfo=ZoneInfo("UTC"))
-def load_flights(data_dir: str) -> list[StrDict]:
- """Load flights."""
+def load_flight_bookings(data_dir: str) -> list[StrDict]:
+ """Load flight bookings."""
bookings = load_travel("flight", data_dir)
airlines = yaml.safe_load(open(os.path.join(data_dir, "airlines.yaml")))
airports = travel.parse_yaml("airports", data_dir)
- flights = []
for booking in bookings:
for flight in booking["flights"]:
if flight["from"] in airports:
@@ -81,10 +80,17 @@ def load_flights(data_dir: str) -> list[StrDict]:
flight["airline_name"] = airlines.get(flight["airline"], "[unknown]")
flight["distance"] = travel.flight_distance(flight)
- flight["type"] = booking["type"]
- flight["trip"] = booking["trip"]
- if "booking_reference" in booking:
- flight["booking_reference"] = booking["booking_reference"]
+ return bookings
+
+
+def load_flights(data_dir: str) -> list[StrDict]:
+ """Load flights."""
+ flights = []
+ for booking in load_flight_bookings(data_dir):
+ for flight in booking["flights"]:
+ for f in "type", "trip", "booking_reference":
+ if f in booking:
+ flight[f] = booking[f]
flights.append(flight)
return flights
diff --git a/templates/macros.html b/templates/macros.html
index a20a753..bab1665 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -90,6 +90,49 @@
{% endmacro %}
+{% macro flight_booking_row(booking) %}
+
{{ booking.booking_reference or "reference missing" }}
+
+ {% if g.user.is_authenticated and booking.price and booking.currency %}
+ {{ "{:,f}".format(booking.price) }} {{ booking.currency }}
+ {% if booking.currency != "GBP" %}
+ {{ "{:,.2f}".format(booking.price / fx_rate[booking.currency]) }} GBP
+ {% endif %}
+ {% endif %}
+
+ {% for i in range(8) %}
+
+ {% endfor %}
+
+ {% for item in booking.flights %}
+ {% set full_flight_number = item.airline + item.flight_number %}
+ {% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %}
+
+
+ {{ 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 }}
+ {{ full_flight_number }}
+
+
+ {% if item.distance %}
+ {{ "{:,.0f} km / {:,.0f} miles".format(item.distance, item.distance / 1.60934) }}
+ {% endif %}
+
+ {% endfor %}
+{% endmacro %}
+
{% macro flight_row(item) %}
{% set full_flight_number = item.airline + item.flight_number %}
{% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %}
diff --git a/templates/travel.html b/templates/travel.html
index 3772d0e..06d1d4e 100644
--- a/templates/travel.html
+++ b/templates/travel.html
@@ -1,15 +1,16 @@
{% extends "base.html" %}
-{% from "macros.html" import flight_row, train_row with context %}
+{% from "macros.html" import flight_booking_row, train_row with context %}
{% block title %}Travel - Edward Betts{% endblock %}
+{% set flight_column_count = 10 %}
{% set column_count = 10 %}
{% block style %}