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) {
|
||||
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) {
|
||||
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;
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, Templat
|
|||
infoline = str(
|
||||
schedule.event.settings.broadcast_tools_lower_thirds_info_string or ""
|
||||
)
|
||||
try:
|
||||
return JsonResponse(
|
||||
{
|
||||
"rooms": sorted(
|
||||
|
@ -110,3 +111,17 @@ class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, Templat
|
|||
],
|
||||
},
|
||||
)
|
||||
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),
|
||||
],
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue