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:
parent
8cdb391dae
commit
2b02350e29
2 changed files with 69 additions and 43 deletions
|
@ -18,7 +18,7 @@ function update_lower_third() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event_info) {
|
if (!event_info) {
|
||||||
console.warn("There's no event info yet, exiting");
|
console.warn("Waiting for event info ...");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,17 @@ function update_lower_third() {
|
||||||
return
|
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)) {
|
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||||
$('#l3title').text('Error')
|
$('#l3title').text('Error')
|
||||||
$('#l3speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
$('#l3speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
||||||
|
$('#l3info_line').text('');
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +84,11 @@ function update_schedule() {
|
||||||
$('#l3box').css('background-color', data['color']);
|
$('#l3box').css('background-color', data['color']);
|
||||||
});
|
});
|
||||||
$.getJSON('../schedule.json', function(data) {
|
$.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;
|
schedule = data;
|
||||||
|
|
||||||
|
|
|
@ -67,46 +67,61 @@ class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, Templat
|
||||||
infoline = str(
|
infoline = str(
|
||||||
schedule.event.settings.broadcast_tools_lower_thirds_info_string or ""
|
schedule.event.settings.broadcast_tools_lower_thirds_info_string or ""
|
||||||
)
|
)
|
||||||
return JsonResponse(
|
try:
|
||||||
{
|
return JsonResponse(
|
||||||
"rooms": sorted(
|
{
|
||||||
{
|
"rooms": sorted(
|
||||||
str(room["name"])
|
{
|
||||||
|
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 day in schedule.data
|
||||||
for room in day["rooms"]
|
for room in day["rooms"]
|
||||||
}
|
for talk in room["talks"]
|
||||||
),
|
],
|
||||||
"talks": [
|
},
|
||||||
{
|
)
|
||||||
"id": talk.submission.id,
|
except KeyError as e:
|
||||||
"start": talk.start.astimezone(tz).isoformat(),
|
key = str(e)[1:-1]
|
||||||
"end": (talk.start + dt.timedelta(minutes=talk.duration))
|
return JsonResponse({
|
||||||
.astimezone(tz)
|
'error': [
|
||||||
.isoformat(),
|
f'Could not find value for placeholder {{{key}}} in info line.',
|
||||||
"slug": talk.frab_slug,
|
f'If you want to use {{{key}}} without evaluating it, please use as follows: {{{{{key}}}}}',
|
||||||
"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"]
|
|
||||||
],
|
],
|
||||||
},
|
})
|
||||||
)
|
except Exception as e:
|
||||||
|
return JsonResponse({
|
||||||
|
'error': [
|
||||||
|
repr(e),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue