dont expose ids of empty subtitles, fixes #1333

This commit is contained in:
j 2013-03-02 08:57:39 +00:00
parent 05bd43e878
commit 661e005b78
3 changed files with 14 additions and 5 deletions

View file

@ -15,7 +15,7 @@ import ox
from clip.models import Clip from clip.models import Clip
from changelog.models import Changelog from changelog.models import Changelog
from item.utils import sort_string from item.utils import sort_string, get_by_key
import managers import managers
import utils import utils
from tasks import update_matches from tasks import update_matches
@ -235,6 +235,10 @@ class Annotation(models.Model):
streams = self.item.streams() streams = self.item.streams()
if streams: if streams:
j['videoRatio'] = streams[0].aspect_ratio 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 return j
def log(self): def log(self):

View file

@ -123,7 +123,8 @@ def findClips(request):
def add_annotations(key, qs, add_layer=False): def add_annotations(key, qs, add_layer=False):
values = ['public_id', 'value', 'clip__start', 'clip__end'] 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') values.append('layer')
if query['filter']: if query['filter']:
qs = qs.filter(query['filter']) qs = qs.filter(query['filter'])
@ -137,6 +138,8 @@ def findClips(request):
'id': a['public_id'], 'id': a['public_id'],
'value': a['value'], 'value': a['value'],
} }
if a['layer'] == subtitles['id'] and not a['value']:
del l['id']
if add_layer: if add_layer:
l['layer'] = a['layer'] l['layer'] = a['layer']
i[key].append(l) i[key].append(l)

View file

@ -119,16 +119,18 @@ pandora.ui.clipList = function(videoRatio) {
Ox.print(data.ids[0], '$$$$$', that.value(data.ids[0])) Ox.print(data.ids[0], '$$$$$', that.value(data.ids[0]))
var id = data.ids[0], var id = data.ids[0],
item = !ui.item ? id.split('/')[0] : ui.item, item = !ui.item ? id.split('/')[0] : ui.item,
annotation = that.value(id, 'annotations')[0].id,
points = { points = {
annotation: that.value(id, 'annotations')[0].id.split('/')[1], annotation: annotation ? annotation.split('/')[1] : '',
'in': that.value(id, 'in'), 'in': that.value(id, 'in'),
out: that.value(id, 'out'), out: that.value(id, 'out'),
position: that.value(id, 'in') position: that.value(id, 'in')
}, },
set; set;
if (isEmbed) { if (isEmbed) {
// FIXME: This is wrong, see ticket #1333. window.open( '/' + item + '/'
window.open('/' + item + '/' + points.annotation, '_blank'); + (annotation ? points.annotation : points['in'] + ',' + points.out),
'_blank');
} else { } else {
set = { set = {
item: item, item: item,