From a022c37d81bbb208becc377c2cd6cb0f5cebb382 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 25 Feb 2011 16:03:41 +0100 Subject: [PATCH] add first annotation --- pandora/annotation/views.py | 12 ++++++------ static/js/pandora.js | 15 +++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index 20a6938b..6af1e6d9 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -49,7 +49,8 @@ def addAnnotation(request): } return {'status': {'code': int, 'text': string}, 'data': { - 'annotation': {}s + id: 123, + ... } } ''' @@ -72,8 +73,7 @@ def addAnnotation(request): start=float(data['in']), end=float(data['out']), value=data['value']) annotation.save() - response = json_response() - response['data']['annotation'] = annotation.json() + response = json_response(annotation.json()) return render_to_json_response(response) response = {'status': {'code': 501, 'text': 'not implemented'}} @@ -119,6 +119,8 @@ def editAnnotation(request): } return {'status': {'code': int, 'text': string}, 'data': { + id: + ... } } ''' @@ -130,10 +132,8 @@ def editAnnotation(request): a.start = data['in'] a.end = data['out'] a.save() + response['data'] = a.json() else: response = json_response(status=403, text='permission denied') return render_to_json_response(response) - - response = json_response(status=501, text='not implemented') - return render_to_json_response(response) actions.register(editAnnotation, cache=False) diff --git a/static/js/pandora.js b/static/js/pandora.js index 35c0969f..cd94c096 100755 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -1825,16 +1825,7 @@ video.width = parseInt(video.height * video.aspectRatio / 2) * 2; video.url = video.baseUrl + '/' + video.height + 'p.' + format; $.each(app.config.layers, function(i, layer) { - layers[i] = $.extend({}, layer); - if (result.data.item.layers[layer.id]) - layers[i]['items'] = result.data.item.layers[layer.id]; - else - layers[i]['items'] = [{ - 'in': 5, - 'out': 10, - 'value': 'This annotation is just a test...' - }]; - + layers[i] = $.extend({}, layer, {items: result.data.item.layers[layer.id]}); }); app.$ui.contentPanel.replace(1, app.$ui.editor = new Ox.VideoEditor({ annotationsSize: app.user.ui.annotationsSize, @@ -1872,9 +1863,9 @@ addAnnotation: function(event, data) { Ox.print('addAnnotation', data); data.item = app.user.ui.item; - data.value = 'Click to change text'; + data.value = 'Click to edit'; pandora.api.addAnnotation(data, function(result) { - app.$ui.editor.addAnnotation(data.layer, result.data.annotation); + app.$ui.editor.addAnnotation(data.layer, result.data); }); }, removeAnnotations: function(event, data) {