forked from 0x2620/pandora
remove list option from addDocument, fixes #2032
This commit is contained in:
parent
07f6e46509
commit
49057ac14a
1 changed files with 11 additions and 13 deletions
|
@ -23,9 +23,7 @@ def addDocument(request):
|
||||||
'''
|
'''
|
||||||
add document(s) to item
|
add document(s) to item
|
||||||
takes {
|
takes {
|
||||||
item: string
|
item: string or [string]
|
||||||
or:
|
|
||||||
list: string
|
|
||||||
|
|
||||||
id: string
|
id: string
|
||||||
or
|
or
|
||||||
|
@ -41,20 +39,20 @@ def addDocument(request):
|
||||||
else:
|
else:
|
||||||
ids = [data['id']]
|
ids = [data['id']]
|
||||||
if 'item' in data:
|
if 'item' in data:
|
||||||
item = Item.objects.get(itemId=data['item'])
|
if isinstance(data['item'], basestring):
|
||||||
if item.editable(request.user):
|
item = Item.objects.get(itemId=data['item'])
|
||||||
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 item.editable(request.user):
|
if item.editable(request.user):
|
||||||
for id in ids:
|
for id in ids:
|
||||||
document = models.Document.get(id)
|
document = models.Document.get(id)
|
||||||
document.add(item)
|
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)
|
return render_to_json_response(response)
|
||||||
actions.register(addDocument, cache=False)
|
actions.register(addDocument, cache=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue