Support nested conference dates in trips
This commit is contained in:
parent
57b2db205d
commit
56eea3f7a3
1 changed files with 11 additions and 5 deletions
|
|
@ -11,7 +11,7 @@ import flask
|
||||||
import pycountry
|
import pycountry
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from agenda import ical, travel, trip_schengen
|
from agenda import conference, ical, travel, trip_schengen
|
||||||
from agenda.types import StrDict, Trip, TripElement
|
from agenda.types import StrDict, Trip, TripElement
|
||||||
from agenda.utils import as_date, as_datetime, depart_datetime
|
from agenda.utils import as_date, as_datetime, depart_datetime
|
||||||
|
|
||||||
|
|
@ -333,12 +333,18 @@ def build_trip_list(
|
||||||
yaml_trip_list = travel.parse_yaml("trips", data_dir)
|
yaml_trip_list = travel.parse_yaml("trips", data_dir)
|
||||||
|
|
||||||
flight_bookings = load_flight_bookings(data_dir)
|
flight_bookings = load_flight_bookings(data_dir)
|
||||||
|
conferences = travel.parse_yaml("conferences", data_dir)
|
||||||
|
for conf in conferences:
|
||||||
|
date_fields = conference.conference_date_fields(conf)
|
||||||
|
if "start" in date_fields:
|
||||||
|
conf["start"] = date_fields["start"]
|
||||||
|
conf["end"] = date_fields["end"]
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"flight_bookings": flight_bookings,
|
"flight_bookings": flight_bookings,
|
||||||
"travel": collect_travel_items(flight_bookings, data_dir, route_distances),
|
"travel": collect_travel_items(flight_bookings, data_dir, route_distances),
|
||||||
"accommodation": travel.parse_yaml("accommodation", data_dir),
|
"accommodation": travel.parse_yaml("accommodation", data_dir),
|
||||||
"conferences": travel.parse_yaml("conferences", data_dir),
|
"conferences": conferences,
|
||||||
"events": travel.parse_yaml("events", data_dir),
|
"events": travel.parse_yaml("events", data_dir),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -467,10 +473,10 @@ def conference_free_days(trip: Trip) -> dict[str, tuple[int, int]]:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def conf_attend_start(c: StrDict) -> date:
|
def conf_attend_start(c: StrDict) -> date:
|
||||||
return as_date(c.get("attend_start") or c["start"])
|
return typing.cast(date, as_date(c.get("attend_start") or c["start"]))
|
||||||
|
|
||||||
def conf_attend_end(c: StrDict) -> date:
|
def conf_attend_end(c: StrDict) -> date:
|
||||||
return as_date(c.get("attend_end") or c["end"])
|
return typing.cast(date, as_date(c.get("attend_end") or c["end"]))
|
||||||
|
|
||||||
sorted_confs = sorted(trip.conferences, key=conf_attend_start)
|
sorted_confs = sorted(trip.conferences, key=conf_attend_start)
|
||||||
result: dict[str, tuple[int, int]] = {}
|
result: dict[str, tuple[int, int]] = {}
|
||||||
|
|
@ -864,7 +870,7 @@ def _trip_element_label(element: TripElement) -> str:
|
||||||
return start_loc
|
return start_loc
|
||||||
if isinstance(end_loc, str):
|
if isinstance(end_loc, str):
|
||||||
return end_loc
|
return end_loc
|
||||||
return element.title
|
return typing.cast(str, element.title)
|
||||||
|
|
||||||
|
|
||||||
def _trip_element_summary(trip: Trip, element: TripElement) -> str:
|
def _trip_element_summary(trip: Trip, element: TripElement) -> str:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue