Add page to generate a list of trips as text
This commit is contained in:
parent
6c8e1bf48d
commit
8b777e64fc
3 changed files with 110 additions and 0 deletions
|
|
@ -66,6 +66,25 @@ class Trip:
|
|||
max_date = max(max_conference_end, travel_end, accommodation_end)
|
||||
return max_date if max_date != datetime.date.min else None
|
||||
|
||||
def locations(self) -> list[tuple[str, Country]]:
|
||||
"""Locations for trip."""
|
||||
seen: set[tuple[str, str]] = set()
|
||||
items = []
|
||||
|
||||
for item in self.conferences + self.accommodation + self.events:
|
||||
if "country" not in item or "location" not in item:
|
||||
continue
|
||||
key = (item["location"], item["country"])
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
|
||||
country = agenda.get_country(item["country"])
|
||||
assert country
|
||||
items.append((item["location"], country))
|
||||
|
||||
return items
|
||||
|
||||
@property
|
||||
def countries(self) -> list[Country]:
|
||||
"""Countries visited as part of trip, in order."""
|
||||
|
|
@ -90,6 +109,13 @@ class Trip:
|
|||
[f"{c.flag} {c.name}" for c in self.countries]
|
||||
)
|
||||
|
||||
@property
|
||||
def locations_str(self) -> str:
|
||||
"""List of countries visited on this trip."""
|
||||
return format_list_with_ampersand(
|
||||
[f"{location} {c.flag}" for location, c in self.locations()]
|
||||
)
|
||||
|
||||
@property
|
||||
def country_flags(self) -> str:
|
||||
"""Countries flags for trip."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue