@@ -33,7 +33,7 @@ class PretalxSlot(BaseModel):
3333 @classmethod
3434 def handle_localized (cls , v ) -> str | None :
3535 if isinstance (v , dict ):
36- return v .get ("en" )
36+ return v [ "name" ] .get ("en" )
3737 return v
3838
3939
@@ -45,7 +45,7 @@ class PretalxSpeaker(BaseModel):
4545 code : str
4646 name : str
4747 biography : str | None = None
48- avatar : str
48+ avatar_url : str
4949 submissions : list [str ]
5050 answers : list [PretalxAnswer ]
5151
@@ -77,7 +77,7 @@ class PretalxSubmission(BaseModel):
7777 @classmethod
7878 def handle_localized (cls , v ) -> str | None :
7979 if isinstance (v , dict ):
80- return v .get ("en" )
80+ return v [ "name" ] .get ("en" )
8181 return v
8282
8383 @field_validator ("duration" , mode = "before" )
@@ -95,11 +95,18 @@ def handle_resources(cls, v) -> list[dict[str, str]] | None:
9595 @model_validator (mode = "before" )
9696 @classmethod
9797 def process_values (cls , values ) -> dict :
98- values ["speakers" ] = sorted ([s ["code" ] for s in values ["speakers" ]])
98+ # Transform resource information
99+ if raw_resources := values .get ("resources" ):
100+ resources = [
101+ {"description" : res ["description" ], "resource" : res ["resource" ]}
102+ for res in raw_resources
103+ ]
104+ values ["resources" ] = resources
99105
100106 # Set slot information
101- if values .get ("slot" ):
102- slot = PretalxSlot .model_validate (values ["slot" ])
107+ if values .get ("slots" ):
108+ slot = PretalxSlot .model_validate (values ["slots" ][0 ])
109+ values ["slot" ] = slot
103110 values ["room" ] = slot .room
104111 values ["start" ] = slot .start
105112 values ["end" ] = slot .end
@@ -146,3 +153,31 @@ class PretalxSchedule(BaseModel):
146153
147154 slots : list [PretalxSubmission ]
148155 breaks : list [PretalxScheduleBreak ]
156+
157+ @model_validator (mode = "before" )
158+ @classmethod
159+ def process_values (cls , values ) -> dict :
160+ submission_slots = []
161+ break_slots = []
162+ for slot_dict in values ["slots" ]:
163+ # extract nested slot fields into slot
164+ slot_object = PretalxSlot .model_validate (slot_dict )
165+ slot_dict ["slot" ] = slot_object
166+ slot_dict ["room" ] = slot_object .room
167+ slot_dict ["start" ] = slot_object .start
168+ slot_dict ["end" ] = slot_object .end
169+
170+ if slot_dict .get ("submission" ) is None :
171+ break_slots .append (slot_dict )
172+ else :
173+ # merge submission fields into slot
174+ slot_dict .update (slot_dict .get ("submission" , {}))
175+
176+ # remove resource IDs (not expandable with API, not required for schedule)
177+ slot_dict .pop ("resources" , None )
178+
179+ submission_slots .append (slot_dict )
180+
181+ values ["slots" ] = submission_slots
182+ values ["breaks" ] = break_slots
183+ return values
0 commit comments