From 5936868018eb192e75975b6926940bdc01cd55e9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 1 Aug 2011 19:57:26 +0200 Subject: [PATCH] remove item --- pandora/item/views.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora/item/views.py b/pandora/item/views.py index 5dd0713ed..64e09bebf 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -393,22 +393,25 @@ def editItem(request): actions.register(editItem, cache=False) @login_required_json -def removeItem(request): +def remove(request): ''' - param data - string id + param data { + id: string + } return {'status': {'code': int, 'text': string}} ''' response = json_response({}) - itemId = json.loads(request.POST['data']) - item = get_object_or_404_json(models.Item, itemId=itemId) + data = json.loads(request.POST['data']) + item = get_object_or_404_json(models.Item, itemId=data['id']) if item.editable(request.user): - response = json_response(status=501, text='not implemented') + #FIXME: is this cascading enough or do we end up with orphan files etc. + item.delete() + response = json_response(status=200, text='removed') else: response = json_response(status=403, text='permission denied') return render_to_json_response(response) -actions.register(removeItem, cache=False) +actions.register(remove, cache=False) ''' Poster API