Add events to trips

This commit is contained in:
Edward Betts 2024-01-10 13:27:25 +00:00
parent 8504a3a022
commit ad47f291f8
2 changed files with 8 additions and 3 deletions

View file

@ -29,13 +29,17 @@ class Trip:
travel: list[StrDict] = field(default_factory=list) travel: list[StrDict] = field(default_factory=list)
accommodation: list[StrDict] = field(default_factory=list) accommodation: list[StrDict] = field(default_factory=list)
conferences: list[StrDict] = field(default_factory=list) conferences: list[StrDict] = field(default_factory=list)
events: list[StrDict] = field(default_factory=list)
@property @property
def title(self) -> str: def title(self) -> str:
"""Trip title.""" """Trip title."""
return ( return (
format_list_with_ampersand([conf["name"] for conf in self.conferences]) format_list_with_ampersand(
or "[no conference]" [conf["name"] for conf in self.conferences]
+ [event["title"] for event in self.events]
)
or "[unnamed trip]"
) )
@property @property
@ -60,7 +64,7 @@ class Trip:
"""Countries visited as part of trip, in order.""" """Countries visited as part of trip, in order."""
seen: set[str] = set() seen: set[str] = set()
items: list[Country] = [] items: list[Country] = []
for item in self.conferences + self.accommodation: for item in self.conferences + self.accommodation + self.events:
if "country" not in item: if "country" not in item:
continue continue
if item["country"] in seen: if item["country"] in seen:

View file

@ -178,6 +178,7 @@ def build_trip_list() -> list[Trip]:
"travel": travel_items, "travel": travel_items,
"accommodation": travel.parse_yaml("accommodation", data_dir), "accommodation": travel.parse_yaml("accommodation", data_dir),
"conferences": travel.parse_yaml("conferences", data_dir), "conferences": travel.parse_yaml("conferences", data_dir),
"events": travel.parse_yaml("events", data_dir),
} }
for key, item_list in data.items(): for key, item_list in data.items():