From 50127417f0b1c696269f0e70584879d38f2bf9cc Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 6 Jan 2024 09:21:54 +0000 Subject: [PATCH] Show trip country list in order visited --- agenda/types.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/agenda/types.py b/agenda/types.py index bf69cb7..1e0ba44 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -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: