From b4cc3621ff4e41894f5b0db96a8a0457fa2af5db Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 19 Jan 2012 00:33:29 +0530 Subject: [PATCH] fix view with clips --- pandora/item/models.py | 10 ++++++---- pandora/item/views.py | 9 ++++----- static/js/pandora/itemClips.js | 6 +++++- static/js/pandora/utils.js | 3 ++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index f4a8600a9..8517a3da2 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -567,12 +567,14 @@ class Item(models.Model): elif i == 'filename': save(i, '\n'.join([f.path for f in self.files.all()])) + elif key['id'] == 'annotations': + qs = Annotation.objects.filter(item=self) + qs = qs.filter(layer__in=Annotation.public_layers()) + qs = qs.order_by('start') + save(i, u'\n'.join([l.findvalue for l in qs])) elif key['type'] == 'layer': qs = Annotation.objects.filter(item=self) - if i == 'annotations': - qs = qs.filter(layer__in=Annotation.public_layers()) - else: - qs = qs.filter(layer=i) + qs = qs.filter(layer=i) qs = qs.order_by('start') save(i, u'\n'.join([l.findvalue for l in qs])) elif i != '*' and i not in self.facet_keys: diff --git a/pandora/item/views.py b/pandora/item/views.py index f409daa88..a12aaca01 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -91,12 +91,11 @@ def parse_query(data, user): if key in data: query[key] = data[key] query['qs'] = models.Item.objects.find(data, user) - if 'clips' in data: - query['clip_qs'] = Clip.objects.find({'query': data['clips']['query']}, - user).order_by('start') - query['clip_filter'] = Clip.objects.find({'query': data['clips']['query']}, - user) + conditions = {'query': data['clips']['query']} + query['clip_qs'] = Clip.objects.find(conditions, user).order_by('start') + conditions = {'query': data['query']} + query['clip_filter'] = models.Clip.objects.filter_annotations(conditions, user) query['clip_items'] = data['clips'].get('items', 5) query['clip_keys'] = data['clips'].get('keys') if not query['clip_keys']: diff --git a/static/js/pandora/itemClips.js b/static/js/pandora/itemClips.js index 2c9cbd15c..27b80aa39 100644 --- a/static/js/pandora/itemClips.js +++ b/static/js/pandora/itemClips.js @@ -3,6 +3,7 @@ pandora.ui.itemClips = function(options) { var self = {}, + textKey = pandora.getClipTextKey(), that = Ox.Element() .css({ height: '192px', @@ -28,7 +29,10 @@ pandora.ui.itemClips = function(options) { Ox.Log('', 'CLIP', clip) var id = self.options.id + '/' + clip['in'], title = Ox.map(clip.annotations, function(annotation) { - return annotation.layer == 'subtitles' ? annotation.value : 0 + if(textKey == 'subtitles') { + return annotation.layer == 'subtitles' ? annotation.value : 0; + } + return annotation.value; }), url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg', $item = Ox.IconItem({ diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index bb717585d..b480668e4 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -480,7 +480,8 @@ pandora.getClipsQuery = function() { if (condition.conditions) { addClipsConditions(condition.conditions); } else if ( - Ox.getIndexById(pandora.site.layers, condition.key) > -1 + (condition.key == 'annotations' + ||Ox.getIndexById(pandora.site.layers, condition.key) > -1) && condition.operator == '=' ) { clipsQuery.conditions.push(condition);