diff --git a/agenda/types.py b/agenda/types.py
index 472db94..2b759b6 100644
--- a/agenda/types.py
+++ b/agenda/types.py
@@ -45,6 +45,8 @@ class TripElement:
end_time: DateOrDateTime | None = None
start_loc: str | None = None
end_loc: str | None = None
+ start_country: Country | None = None
+ end_country: Country | None = None
def get_emoji(self) -> str | None:
"""Emoji for trip element."""
@@ -63,9 +65,7 @@ class TripElement:
def airport_label(airport: StrDict) -> str:
"""Airport label: name and iata."""
name = airport.get("alt_name") or airport["city"]
- country = agenda.get_country(airport["country"])
- assert country and country.flag
- return f"{name} ({airport['iata']}) {country.flag}"
+ return f"{name} ({airport['iata']})"
@dataclass
@@ -234,6 +234,9 @@ class Trip:
+ f"{airport_label(item['to_airport'])}"
)
+ from_country = agenda.get_country(item["from_airport"]["country"])
+ to_country = agenda.get_country(item["to_airport"]["country"])
+
elements.append(
TripElement(
start_time=item["depart"],
@@ -243,6 +246,8 @@ class Trip:
element_type="flight",
start_loc=airport_label(item["from_airport"]),
end_loc=airport_label(item["to_airport"]),
+ start_country=from_country,
+ end_country=to_country,
)
)
if item["type"] == "train":
@@ -251,9 +256,7 @@ class Trip:
to_country = agenda.get_country(leg["to_station"]["country"])
assert from_country and to_country
- from_flag = from_country.flag
- to_flag = to_country.flag
- name = f"{leg['from']} {from_flag} → {leg['to']} {to_flag}"
+ name = f"{leg['from']} → {leg['to']}"
elements.append(
TripElement(
start_time=leg["depart"],
@@ -261,19 +264,17 @@ class Trip:
title=name,
detail=leg,
element_type="train",
- start_loc=f"{leg['from']} {from_flag}",
- end_loc=f"{leg['to']} {to_flag}",
+ start_loc=leg["from"],
+ end_loc=leg["to"],
+ start_country=from_country,
+ end_country=to_country,
)
)
if item["type"] == "ferry":
from_country = agenda.get_country(item["from_terminal"]["country"])
to_country = agenda.get_country(item["to_terminal"]["country"])
- assert from_country and to_country
- from_flag = from_country.flag
- to_flag = to_country.flag
-
- name = f"{item['from']} {from_flag} → {item['to']} {to_flag}"
+ name = f"{item['from']} → {item['to']}"
elements.append(
TripElement(
start_time=item["depart"],
@@ -281,8 +282,10 @@ class Trip:
title=name,
detail=item,
element_type="ferry",
- start_loc=f"{item['from']} {from_flag}",
- end_loc=f"{item['to']} {to_flag}",
+ start_loc=item["from"],
+ end_loc=item["to"],
+ start_country=from_country,
+ end_country=to_country,
)
)
diff --git a/templates/trip/list.html b/templates/trip/list.html
index 346f186..eb0900b 100644
--- a/templates/trip/list.html
+++ b/templates/trip/list.html
@@ -118,11 +118,11 @@
{{ e.get_emoji() }}
{{ display_time(e.start_time) }}
–
- {{ e.start_loc }}
+ {{ e.start_loc }} {{ e.start_country.flag }}
→
{{ display_time(e.end_time) }}
–
- {{ e.end_loc }}
+ {{ e.end_loc }} {{ e.end_country.flag }}
{% if e.element_type == "flight" %}
airline: {{ e.detail.airline_name }}
flight number: {{ e.detail.airline }}{{ e.detail.flight_number }}