Show trip country list in order visited

This commit is contained in:
Edward Betts 2024-01-06 09:21:54 +00:00
parent fd6d3b674b
commit 50127417f0

View file

@ -55,17 +55,21 @@ class Trip:
return max_date if max_date != date.min else None
@property
def countries(self) -> set[Country]:
"""Trip countries."""
found: set[Country] = set()
def countries(self) -> list[Country]:
"""Countries visited as part of trip, in order."""
seen: set[str] = set()
items: list[Country] = []
for item in self.conferences + self.accommodation:
if "country" not in item:
continue
if item["country"] in seen:
continue
seen.add(item["country"])
country = agenda.get_country(item["country"])
assert country
found.add(country)
items.append(country)
return found
return items
@property
def countries_str(self) -> str: