From ad47f291f8f32a8fbd2a770ba0c7fbacfed32bd9 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 10 Jan 2024 13:27:25 +0000 Subject: [PATCH] Add events to trips --- agenda/types.py | 10 +++++++--- web_view.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/agenda/types.py b/agenda/types.py index 293e977..84cbc59 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -29,13 +29,17 @@ class Trip: travel: list[StrDict] = field(default_factory=list) accommodation: list[StrDict] = field(default_factory=list) conferences: list[StrDict] = field(default_factory=list) + events: list[StrDict] = field(default_factory=list) @property def title(self) -> str: """Trip title.""" return ( - format_list_with_ampersand([conf["name"] for conf in self.conferences]) - or "[no conference]" + format_list_with_ampersand( + [conf["name"] for conf in self.conferences] + + [event["title"] for event in self.events] + ) + or "[unnamed trip]" ) @property @@ -60,7 +64,7 @@ class Trip: """Countries visited as part of trip, in order.""" seen: set[str] = set() items: list[Country] = [] - for item in self.conferences + self.accommodation: + for item in self.conferences + self.accommodation + self.events: if "country" not in item: continue if item["country"] in seen: diff --git a/web_view.py b/web_view.py index 5cc1d89..2ee8b01 100755 --- a/web_view.py +++ b/web_view.py @@ -178,6 +178,7 @@ def build_trip_list() -> list[Trip]: "travel": travel_items, "accommodation": travel.parse_yaml("accommodation", data_dir), "conferences": travel.parse_yaml("conferences", data_dir), + "events": travel.parse_yaml("events", data_dir), } for key, item_list in data.items():