1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-24 10:01:02 +00:00

add some error handling for lower thirds placeholders

This commit is contained in:
Franzi 2022-11-08 19:43:17 +01:00
parent 8cdb391dae
commit 2b02350e29
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 69 additions and 43 deletions

View file

@ -18,7 +18,7 @@ function update_lower_third() {
}
if (!event_info) {
console.warn("There's no event info yet, exiting");
console.warn("Waiting for event info ...");
return
}
@ -27,10 +27,17 @@ function update_lower_third() {
return
}
if ('error' in schedule) {
$('#l3title').text('Error')
$('#l3speaker').html(schedule['error'].join('<br>'));
$('#l3info_line').text('');
return
}
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
$('#l3title').text('Error')
$('#l3speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
$('#l3info_line').text('');
return
}
@ -77,7 +84,11 @@ function update_schedule() {
$('#l3box').css('background-color', data['color']);
});
$.getJSON('../schedule.json', function(data) {
console.info('schedule updated with ' + data['talks'].length + ' talks in ' + data['rooms'].length + ' rooms');
if ('error' in data) {
console.error(data['error']);
} else {
console.info('schedule updated with ' + data['talks'].length + ' talks in ' + data['rooms'].length + ' rooms');
}
schedule = data;

View file

@ -67,46 +67,61 @@ class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, Templat
infoline = str(
schedule.event.settings.broadcast_tools_lower_thirds_info_string or ""
)
return JsonResponse(
{
"rooms": sorted(
{
str(room["name"])
try:
return JsonResponse(
{
"rooms": sorted(
{
str(room["name"])
for day in schedule.data
for room in day["rooms"]
}
),
"talks": [
{
"id": talk.submission.id,
"start": talk.start.astimezone(tz).isoformat(),
"end": (talk.start + dt.timedelta(minutes=talk.duration))
.astimezone(tz)
.isoformat(),
"slug": talk.frab_slug,
"title": talk.submission.title,
"persons": sorted(
{
person.get_display_name()
for person in talk.submission.speakers.all()
}
),
"track": {
"color": talk.submission.track.color,
"name": str(talk.submission.track.name),
}
if talk.submission.track
else None,
"room": str(room["name"]),
"infoline": infoline.format(
EVENT_SLUG=str(schedule.event.slug),
TALK_SLUG=talk.frab_slug,
CODE=talk.submission.code,
),
}
for day in schedule.data
for room in day["rooms"]
}
),
"talks": [
{
"id": talk.submission.id,
"start": talk.start.astimezone(tz).isoformat(),
"end": (talk.start + dt.timedelta(minutes=talk.duration))
.astimezone(tz)
.isoformat(),
"slug": talk.frab_slug,
"title": talk.submission.title,
"persons": sorted(
{
person.get_display_name()
for person in talk.submission.speakers.all()
}
),
"track": {
"color": talk.submission.track.color,
"name": str(talk.submission.track.name),
}
if talk.submission.track
else None,
"room": str(room["name"]),
"infoline": infoline.format(
EVENT_SLUG=str(schedule.event.slug),
TALK_SLUG=talk.frab_slug,
CODE=talk.submission.code,
),
}
for day in schedule.data
for room in day["rooms"]
for talk in room["talks"]
for talk in room["talks"]
],
},
)
except KeyError as e:
key = str(e)[1:-1]
return JsonResponse({
'error': [
f'Could not find value for placeholder {{{key}}} in info line.',
f'If you want to use {{{key}}} without evaluating it, please use as follows: {{{{{key}}}}}',
],
},
)
})
except Exception as e:
return JsonResponse({
'error': [
repr(e),
],
})