fix view with clips

This commit is contained in:
j 2012-01-19 00:33:29 +05:30
parent 289e47fa5b
commit b4cc3621ff
4 changed files with 17 additions and 11 deletions

View file

@ -567,11 +567,13 @@ class Item(models.Model):
elif i == 'filename': elif i == 'filename':
save(i, save(i,
'\n'.join([f.path for f in self.files.all()])) '\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': elif key['type'] == 'layer':
qs = Annotation.objects.filter(item=self) 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') qs = qs.order_by('start')
save(i, u'\n'.join([l.findvalue for l in qs])) save(i, u'\n'.join([l.findvalue for l in qs]))

View file

@ -91,12 +91,11 @@ def parse_query(data, user):
if key in data: if key in data:
query[key] = data[key] query[key] = data[key]
query['qs'] = models.Item.objects.find(data, user) query['qs'] = models.Item.objects.find(data, user)
if 'clips' in data: if 'clips' in data:
query['clip_qs'] = Clip.objects.find({'query': data['clips']['query']}, conditions = {'query': data['clips']['query']}
user).order_by('start') query['clip_qs'] = Clip.objects.find(conditions, user).order_by('start')
query['clip_filter'] = Clip.objects.find({'query': data['clips']['query']}, conditions = {'query': data['query']}
user) query['clip_filter'] = models.Clip.objects.filter_annotations(conditions, user)
query['clip_items'] = data['clips'].get('items', 5) query['clip_items'] = data['clips'].get('items', 5)
query['clip_keys'] = data['clips'].get('keys') query['clip_keys'] = data['clips'].get('keys')
if not query['clip_keys']: if not query['clip_keys']:

View file

@ -3,6 +3,7 @@
pandora.ui.itemClips = function(options) { pandora.ui.itemClips = function(options) {
var self = {}, var self = {},
textKey = pandora.getClipTextKey(),
that = Ox.Element() that = Ox.Element()
.css({ .css({
height: '192px', height: '192px',
@ -28,7 +29,10 @@ pandora.ui.itemClips = function(options) {
Ox.Log('', 'CLIP', clip) Ox.Log('', 'CLIP', clip)
var id = self.options.id + '/' + clip['in'], var id = self.options.id + '/' + clip['in'],
title = Ox.map(clip.annotations, function(annotation) { 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', url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg',
$item = Ox.IconItem({ $item = Ox.IconItem({

View file

@ -480,7 +480,8 @@ pandora.getClipsQuery = function() {
if (condition.conditions) { if (condition.conditions) {
addClipsConditions(condition.conditions); addClipsConditions(condition.conditions);
} else if ( } else if (
Ox.getIndexById(pandora.site.layers, condition.key) > -1 (condition.key == 'annotations'
||Ox.getIndexById(pandora.site.layers, condition.key) > -1)
&& condition.operator == '=' && condition.operator == '='
) { ) {
clipsQuery.conditions.push(condition); clipsQuery.conditions.push(condition);