From 661e005b7844b1d77a314dfa9dbaec9fc61ed3c1 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 2 Mar 2013 08:57:39 +0000 Subject: [PATCH] dont expose ids of empty subtitles, fixes #1333 --- pandora/annotation/models.py | 6 +++++- pandora/clip/views.py | 5 ++++- static/js/pandora/clipList.js | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 62174349..f331d6fb 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -15,7 +15,7 @@ import ox from clip.models import Clip from changelog.models import Changelog -from item.utils import sort_string +from item.utils import sort_string, get_by_key import managers import utils from tasks import update_matches @@ -235,6 +235,10 @@ class Annotation(models.Model): streams = self.item.streams() if streams: j['videoRatio'] = streams[0].aspect_ratio + subtitles = get_by_key(settings.CONFIG['layers'], 'isSubtitles', True) + if subtitles: + if 'id' in j and self.layer == subtitles['id'] and not self.value: + del j['id'] return j def log(self): diff --git a/pandora/clip/views.py b/pandora/clip/views.py index 0f2ae7bc..0c89ab53 100644 --- a/pandora/clip/views.py +++ b/pandora/clip/views.py @@ -123,7 +123,8 @@ def findClips(request): def add_annotations(key, qs, add_layer=False): values = ['public_id', 'value', 'clip__start', 'clip__end'] - if add_layer: + subtitles = utils.get_by_key(settings.CONFIG['layers'], 'isSubtitles', True) + if subtitles or add_layer: values.append('layer') if query['filter']: qs = qs.filter(query['filter']) @@ -137,6 +138,8 @@ def findClips(request): 'id': a['public_id'], 'value': a['value'], } + if a['layer'] == subtitles['id'] and not a['value']: + del l['id'] if add_layer: l['layer'] = a['layer'] i[key].append(l) diff --git a/static/js/pandora/clipList.js b/static/js/pandora/clipList.js index e1c43788..3d18ea26 100644 --- a/static/js/pandora/clipList.js +++ b/static/js/pandora/clipList.js @@ -119,16 +119,18 @@ pandora.ui.clipList = function(videoRatio) { Ox.print(data.ids[0], '$$$$$', that.value(data.ids[0])) var id = data.ids[0], item = !ui.item ? id.split('/')[0] : ui.item, + annotation = that.value(id, 'annotations')[0].id, points = { - annotation: that.value(id, 'annotations')[0].id.split('/')[1], + annotation: annotation ? annotation.split('/')[1] : '', 'in': that.value(id, 'in'), out: that.value(id, 'out'), position: that.value(id, 'in') }, set; if (isEmbed) { - // FIXME: This is wrong, see ticket #1333. - window.open('/' + item + '/' + points.annotation, '_blank'); + window.open( '/' + item + '/' + + (annotation ? points.annotation : points['in'] + ',' + points.out), + '_blank'); } else { set = { item: item,