diff --git a/pandora/clip/views.py b/pandora/clip/views.py index 4d691d79..a0453d1e 100644 --- a/pandora/clip/views.py +++ b/pandora/clip/views.py @@ -84,7 +84,7 @@ def findClips(request): qs = qs[query['range'][0]:query['range'][1]] ids = [] - keys = filter(lambda k: k not in models.Clip.layers, data['keys']) + keys = filter(lambda k: k not in models.Clip.layers + ['annotations'], data['keys']) if filter(lambda k: k not in models.Clip.clip_keys, keys): qs = qs.select_related('item__sort') @@ -95,20 +95,27 @@ def findClips(request): keys = data['keys'] - def add_annotations(layer, qs): - for a in qs.values('public_id', 'value', 'clip__public_id'): + def add_annotations(key, qs, add_layer=False): + values = ['public_id', 'value', 'clip__public_id'] + if add_layer: + values.append('layer') + for a in qs.values(*values): for i in response['data']['items']: if i['id'] == a['clip__public_id']: - if not layer in i: - i[layer] = [] - i[layer].append({ + if not key in i: + i[key] = [] + l = { 'id': a['public_id'], 'value': a['value'], - }) + } + if add_layer: + l['layer'] = a['layer'] + i[key].append(l) if response['data']['items']: if 'annotations' in keys: add_annotations('annotations', - Annotation.objects.filter(layer__in=models.Clip.layers, clip__in=ids)) + Annotation.objects.filter(layer__in=models.Clip.layers, clip__in=ids), + True) for layer in filter(lambda l: l in keys, models.Clip.layers): add_annotations(layer, Annotation.objects.filter(layer=layer, clip__in=ids)) diff --git a/static/js/pandora/clipList.js b/static/js/pandora/clipList.js index 8956f589..a93c5436 100644 --- a/static/js/pandora/clipList.js +++ b/static/js/pandora/clipList.js @@ -7,7 +7,9 @@ pandora.ui.clipList = function(videoRatio) { var ui = pandora.user.ui, fixedRatio = !ui.item ? 16/9 : videoRatio, isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips', - + textKey = Ox.getObjectById(pandora.site.layers, 'subtitles') + ? 'subtitles' + : 'annotations', that = Ox.IconList({ fixedRatio: fixedRatio, item: function(data, sort, size) { @@ -22,7 +24,7 @@ pandora.ui.clipList = function(videoRatio) { width = fixedRatio > 1 ? size : Math.round(size * fixedRatio); height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size; } - title = data.subtitles ? data.subtitles[0].value : ''; //fixme: could be other layer + title = data[textKey] ? data[textKey][0].value : ''; url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg'; sortKey = sort[0].key; if (['text', 'position', 'duration'].indexOf(sortKey) > -1) { @@ -79,7 +81,7 @@ pandora.ui.clipList = function(videoRatio) { }, data), callback); }, keys: Ox.merge( - ['id', 'in', 'out', 'subtitles'], //fixme: could be other layer + ['id', 'in', 'out', textKey], !ui.item ? ['videoRatio'] : [] ), max: 1, diff --git a/static/js/pandora/info.js b/static/js/pandora/info.js index da3c58df..d6e78253 100644 --- a/static/js/pandora/info.js +++ b/static/js/pandora/info.js @@ -308,7 +308,7 @@ pandora.ui.posterInfo = function(data) { }) .html( data.title + ( - data.director ? ' (' + data.director.join(', ') + ')' : '' + Ox.len(data.director) ? ' (' + data.director.join(', ') + ')' : '' ) ), that = Ox.SplitPanel({ diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 2eef3bd2..1ab1c2fa 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -32,7 +32,7 @@ pandora.ui.item = function() { pandora.$ui.itemTitle .options({ title: '' + result.data.title - + (result.data.director && result.data.director.length + + (Ox.len(result.data.director) ? ' (' + result.data.director.join(', ') + ')' : '') + (result.data.year ? ' ' + result.data.year : '') + ''