From d4dda44768c1ea12d38aad9c2a36146f748f1668 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 18 May 2024 20:29:29 +0200 Subject: [PATCH] Add more country flags on the trip list. --- agenda/types.py | 4 +++- templates/trip/list.html | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/agenda/types.py b/agenda/types.py index e4bd7e4..be5232f 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -59,7 +59,9 @@ class TripElement: def airport_label(airport: StrDict) -> str: """Airport label: name and iata.""" name = airport.get("alt_name") or airport["city"] - return f"{name} ({airport['iata']})" + country = agenda.get_country(airport["country"]) + assert country and country.flag + return f"{name} ({airport['iata']}) {country.flag}" @dataclass diff --git a/templates/trip/list.html b/templates/trip/list.html index a117384..07dad88 100644 --- a/templates/trip/list.html +++ b/templates/trip/list.html @@ -152,16 +152,13 @@ {% set date_heading = None %} {% for day, elements in trip.elements_grouped_by_day() %}

{{ display_date_no_year(day) }}

+ {% set accommodation_label = {"check-in": "check-in from", "check-out": "check-out by"} %} {% for e in elements %} - {% if e.element_type == "check-in" %} + {% if e.element_type in accommodation_label %} + {% set c = get_country(e.detail.country) %}
- {{ e.get_emoji() }} {{ e.title }} - (check-in from {{ display_time(e.when) }}) -
- {% elif e.element_type == "check-out" %} -
- {{ e.get_emoji() }} {{ e.title }} - (check-out by {{ display_time(e.when) }}) + {{ e.get_emoji() }} {{ e.title }} {{ c.flag }} + ({{ accommodation_label[e.element_type] }} {{ display_time(e.when) }})
{% else %}