From 49057ac14a0b1fcda3b816e2dc3e9b3befd59ff0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 16 Jan 2014 05:30:54 +0000 Subject: [PATCH] remove list option from addDocument, fixes #2032 --- pandora/document/views.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pandora/document/views.py b/pandora/document/views.py index a3d190da..9219987a 100644 --- a/pandora/document/views.py +++ b/pandora/document/views.py @@ -23,9 +23,7 @@ def addDocument(request): ''' add document(s) to item takes { - item: string - or: - list: string + item: string or [string] id: string or @@ -41,20 +39,20 @@ def addDocument(request): else: ids = [data['id']] if 'item' in data: - item = Item.objects.get(itemId=data['item']) - if item.editable(request.user): - for id in ids: - document = models.Document.get(id) - document.add(item) - else: - response = json_response(status=403, text='permission denied') - elif 'list' in data: - list = List.get(data['list']) - for item in list.get_items(request.user): + if isinstance(data['item'], basestring): + item = Item.objects.get(itemId=data['item']) if item.editable(request.user): for id in ids: document = models.Document.get(id) document.add(item) + else: + response = json_response(status=403, text='permission denied') + else: + for item in Item.objects.filter(itemId__in=data['item']): + if item.editable(request.user): + for id in ids: + document = models.Document.get(id) + document.add(item) return render_to_json_response(response) actions.register(addDocument, cache=False)