Add more country flags on the trip list.

This commit is contained in:
Edward Betts 2024-05-18 20:29:29 +02:00
parent 448d59514b
commit d4dda44768
2 changed files with 8 additions and 9 deletions

View file

@ -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

View file

@ -152,16 +152,13 @@
{% set date_heading = None %}
{% for day, elements in trip.elements_grouped_by_day() %}
<h4>{{ display_date_no_year(day) }}</h4>
{% 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) %}
<div>
{{ e.get_emoji() }} {{ e.title }}
(check-in from {{ display_time(e.when) }})
</div>
{% elif e.element_type == "check-out" %}
<div>
{{ 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) }})
</div>
{% else %}
<div>