From 3c9676a32a8d36d86e993d66c4a9b8b52b03c7e4 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 3 Jan 2012 15:56:50 +0530 Subject: [PATCH] update video editor / annotation panel --- pandora/annotation/views.py | 20 ++++++++------------ static/js/pandora/item.js | 28 +++++++++++++++------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index 3865ce1a5..9074aefe3 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -118,7 +118,7 @@ def addAnnotation(request): } return {'status': {'code': int, 'text': string}, 'data': { - id: 123, + id: 123, //id of new annotation ... } } @@ -149,10 +149,10 @@ actions.register(addAnnotation, cache=False) @login_required_json -def removeAnnotations(request): +def removeAnnotation(request): ''' param data { - ids: [] + id: annotationId } return {'status': {'code': int, 'text': string}, 'data': { @@ -161,17 +161,13 @@ def removeAnnotations(request): ''' response = json_response({}) data = json.loads(request.POST['data']) - failed = [] - for a in models.Annotation.objects.filter(public_id__in=data['ids']): - if a.editable(request.user): - a.delete() - else: - failed.append(a.public_id) - if failed: + a = get_object_or_404_json(models.Annotation, public_id=data['id']) + if a.editable(request.user): + a.delete() + else: response = json_response(status=403, text='permission denied') - response['data']['ids'] = failed return render_to_json_response(response) -actions.register(removeAnnotations, cache=False) +actions.register(removeAnnotation, cache=False) @login_required_json diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 0a50c6a1e..49dbaec25 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -287,22 +287,13 @@ pandora.ui.item = function() { item: pandora.user.ui.item, layer: data.layer, out: data.out, - value: 'Click to edit', + value: data.value, }, function(result) { pandora.$ui.editor.addAnnotation(data.layer, result.data); }); }, - removeannotations: function(data) { - pandora.api.removeAnnotations(data, function(result) { - //fixme: check for errors - pandora.$ui.editor.removeAnnotations(data.layer, data.ids); - }); - }, - toggleannotations: function(data) { - pandora.UI.set('showAnnotations', data.showAnnotations); - }, - updateannotation: function(data) { - Ox.Log('', 'editAnnotations', data); + editannotation: function(data) { + Ox.Log('', 'editAnnotation', data); //fixme: check that edit was successfull pandora.api.editAnnotation({ id: data.id, @@ -310,9 +301,20 @@ pandora.ui.item = function() { out: data.out, value: data.value, }, function(result) { - Ox.Log('', 'done updateAnnotation', result); + Ox.Log('', 'editAnnotation result', result); }); }, + removeannotation: function(data) { + pandora.api.removeAnnotation({ + id: data.id + }, function(result) { + //fixme: check for errors + pandora.$ui.editor.removeAnnotation(data.layer, data.id); + }); + }, + toggleannotations: function(data) { + pandora.UI.set('showAnnotations', data.showAnnotations); + }, pandora_showannotations: function(data) { pandora.$ui.editor.options({showAnnotations: data.value}); }