@@ -33,7 +33,7 @@ class PretalxSlot(BaseModel):
33
33
@classmethod
34
34
def handle_localized (cls , v ) -> str | None :
35
35
if isinstance (v , dict ):
36
- return v .get ("en" )
36
+ return v [ "name" ] .get ("en" )
37
37
return v
38
38
39
39
@@ -45,7 +45,7 @@ class PretalxSpeaker(BaseModel):
45
45
code : str
46
46
name : str
47
47
biography : str | None = None
48
- avatar : str
48
+ avatar_url : str
49
49
submissions : list [str ]
50
50
answers : list [PretalxAnswer ]
51
51
@@ -77,7 +77,7 @@ class PretalxSubmission(BaseModel):
77
77
@classmethod
78
78
def handle_localized (cls , v ) -> str | None :
79
79
if isinstance (v , dict ):
80
- return v .get ("en" )
80
+ return v [ "name" ] .get ("en" )
81
81
return v
82
82
83
83
@field_validator ("duration" , mode = "before" )
@@ -95,11 +95,18 @@ def handle_resources(cls, v) -> list[dict[str, str]] | None:
95
95
@model_validator (mode = "before" )
96
96
@classmethod
97
97
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
99
105
100
106
# 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
103
110
values ["room" ] = slot .room
104
111
values ["start" ] = slot .start
105
112
values ["end" ] = slot .end
@@ -146,3 +153,31 @@ class PretalxSchedule(BaseModel):
146
153
147
154
slots : list [PretalxSubmission ]
148
155
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