diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index 0ec94a1..b9a49f0 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -353,41 +353,48 @@ function loadAnnotations(config) { }) } else { var cited = {} - pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => { - var annotations = [] - response.data.clips.forEach(clip => { - cited[clip.item] = { - title: clip.title, - director: clip.director, - id: clip.item - } - layers.forEach(layer => { - clip.layers[layer].forEach(annotation => { - if (config.user && annotation.user != config.user) { - return - } - ;['title', 'director', 'date'].forEach(key => { - annotation[key] = clip[key] - }) - if (config.only_e) { - if (annotation.value.slice(0, 2) == 'E:') { - annotation.value = annotation.value.slice(2).trim() - annotations.push(annotation) + if (config.edit) { + pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => { + var annotations = [] + response.data.clips.forEach(clip => { + cited[clip.item] = { + title: clip.title, + director: clip.director, + id: clip.item + } + layers.forEach(layer => { + clip.layers[layer].forEach(annotation => { + if (config.user && annotation.user != config.user) { + return } - } else { - //if (annotation.value.slice(0, 2) != 'E:') { - annotations.push(annotation) - //} - } + ;['title', 'director', 'date'].forEach(key => { + annotation[key] = clip[key] + }) + if (config.only_e) { + if (annotation.value.slice(0, 2) == 'E:') { + annotation.value = annotation.value.slice(2).trim() + annotations.push(annotation) + } + } else { + //if (annotation.value.slice(0, 2) != 'E:') { + annotations.push(annotation) + //} + } + }) }) }) + loadClips(annotations).then(annotations => { + config.annotations = annotations + config.cited = Object.values(cited) + renderAnnotations(config) + }) }) - loadClips(annotations).then(annotations => { - config.annotations = annotations - config.cited = Object.values(cited) - renderAnnotations(config) - }) - }) + } else { + if (!config.annotations) { + config.annotations = [] + } + renderAnnotations(config) + } } } diff --git a/app/text/admin.py b/app/text/admin.py index cd6728d..115aec6 100644 --- a/app/text/admin.py +++ b/app/text/admin.py @@ -7,6 +7,8 @@ from ..widgets import PrettyJSONWidget @admin.decorators.register(models.Text) class TextAdmin(admin.ModelAdmin): + save_on_top = True + formfield_overrides = { JSONField: {'widget': PrettyJSONWidget} }