remove item

This commit is contained in:
j 2011-08-01 19:57:26 +02:00
parent a80f1f9515
commit 5936868018

View file

@ -393,22 +393,25 @@ def editItem(request):
actions.register(editItem, cache=False) actions.register(editItem, cache=False)
@login_required_json @login_required_json
def removeItem(request): def remove(request):
''' '''
param data param data {
string id id: string
}
return {'status': {'code': int, 'text': string}} return {'status': {'code': int, 'text': string}}
''' '''
response = json_response({}) response = json_response({})
itemId = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
item = get_object_or_404_json(models.Item, itemId=itemId) item = get_object_or_404_json(models.Item, itemId=data['id'])
if item.editable(request.user): 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: else:
response = json_response(status=403, text='permission denied') response = json_response(status=403, text='permission denied')
return render_to_json_response(response) return render_to_json_response(response)
actions.register(removeItem, cache=False) actions.register(remove, cache=False)
''' '''
Poster API Poster API