fix: get speaker biography directly from speaker code

This commit is contained in:
mco-system 2023-05-09 21:22:12 +11:00
parent 3ba116c7fa
commit bda40b1935

View File

@ -59,13 +59,11 @@ def get_slots():
return backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/schedules/{app.local_config['pretalx']['schedule']}/").json() return backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/schedules/{app.local_config['pretalx']['schedule']}/").json()
def get_speaker_biography(name): def get_speaker_biography(code):
try: try:
speaker_info = backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/speakers/", params={"q": name}).json() speaker_info = backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/speakers/{code}/").json()
logger.debug(speaker_info) return speaker_info.get("biography").strip()
return speaker_info["results"][0]["biography"].strip()
except Exception as err: except Exception as err:
logger.warning(f"UnknownSpeakerError: {name} from {str(err)}")
return None return None
@ -126,7 +124,7 @@ def planning():
slots = get_slots() slots = get_slots()
for slot in slots.get("slots"): for slot in slots.get("slots"):
for speaker in slot.get("speakers"): for speaker in slot.get("speakers"):
speaker["biography"] = get_speaker_biography(speaker.get("name")) speaker["biography"] = get_speaker_biography(speaker.get("code"))
return render_template("planning.html", return render_template("planning.html",
slots=sorted(slots.get("slots"), slots=sorted(slots.get("slots"),
key=lambda slot: slot.get("slot").get("start")), key=lambda slot: slot.get("slot").get("start")),