From 1c408c78e523ca89f310f522b00789209c0bd12e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 4 Jan 2012 01:47:44 +0530 Subject: [PATCH] update VideoEditor/AnnotationPanel/Editable integration --- pandora/0xdb.jsonc | 3 ++- pandora/item/models.py | 5 +++-- pandora/padma.jsonc | 3 ++- static/js/pandora/item.js | 6 ++++++ static/js/pandora/utils.js | 9 ++++++++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 923d4986..96413135 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -595,8 +595,9 @@ "newsletter": true, "ui": { "annotationsFont": "small", - "annotationsRange": "all", + "annotationsRange": "position", "annotationsSize": 256, + "annotationsSort": "position", "clipsColumns": 2, "columns": { "Colors": { diff --git a/pandora/item/models.py b/pandora/item/models.py index 5eed3d78..577020eb 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -426,7 +426,8 @@ class Item(models.Model): for l in settings.CONFIG['layers']: name = l['id'] ll = layers.setdefault(name, []) - qs = Annotation.objects.filter(layer=name, item=self) + qs = Annotation.objects.filter(layer=name, item=self).order_by( + 'start', 'end', 'sortvalue') if name == 'subtitles': qs = qs.exclude(value='') if l.get('private'): @@ -1171,7 +1172,7 @@ class Item(models.Model): 'in': a.start, 'out': a.end, 'value': a.value - } for a in self.annotations.filter(layer=layer).order_by('start')]) + } for a in self.annotations.filter(layer=layer).order_by('start', 'end', 'sortvalue')]) def delete_item(sender, **kwargs): i = kwargs['instance'] diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index b65999d1..37f52dfc 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -490,8 +490,9 @@ "level": "guest", "ui": { "annotationsFont": "small", - "annotationsRange": "all", + "annotationsRange": "position", "annotationsSize": 256, + "annotationsSort": "position", "clipsColumns": 2, "columns": { "Colors": { diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 49dbaec2..70284bac 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -197,6 +197,7 @@ pandora.ui.item = function() { annotationsFont: pandora.user.ui.annotationsFont, annotationsRange: pandora.user.ui.annotationsRange, annotationsSize: pandora.user.ui.annotationsSize, + annotationsSort: pandora.user.ui.annotationsSort, censored: videoOptions.censored, cuts: result.data.cuts || [], duration: result.data.duration, @@ -244,6 +245,9 @@ pandora.ui.item = function() { annotationsSize: function(data) { pandora.UI.set({annotationsSize: data.size}); }, + annotationsSort: function(data) { + pandora.UI.set({annotationsSort: data.sort}); + }, find: function(data) { pandora.UI.set('itemFind', data.find ? { conditions: [{key: 'subtitles', value: data.find, operator: '='}], @@ -289,6 +293,8 @@ pandora.ui.item = function() { out: data.out, value: data.value, }, function(result) { + result.data.editable = true; + result.data.duration = result.data.out - result.data['in']; pandora.$ui.editor.addAnnotation(data.layer, result.data); }); }, diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index e7d96f4e..ecf30af0 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -763,7 +763,14 @@ pandora.getVideoOptions = function(data) { }); options.layers = []; pandora.site.layers.forEach(function(layer, i) { - options.layers[i] = Ox.extend({}, layer, {items: data.layers[layer.id]}); + options.layers[i] = Ox.extend({}, layer, { + items: data.layers[layer.id].map(function(annotation) { + annotation.duration = annotation.out - annotation['in']; + annotation.editable = annotation.user == pandora.user.username || + pandora.site.capabilities['canEditAnnotations'][pandora.user.level]; + return annotation; + }) + }); }); return options; };