fix delete
This commit is contained in:
parent
1db95713a2
commit
22cc6a5afc
|
@ -268,15 +268,22 @@ def editFile(request):
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@user_passes_test_json(canEditFile)
|
|
||||||
def deleteFiles(request):
|
def deleteFiles(request):
|
||||||
files = json.loads(request.POST.get("ids", "[]"))
|
|
||||||
for f in files:
|
|
||||||
fil = File.objects.get(pk=f)
|
|
||||||
fil.delete()
|
|
||||||
response = {
|
response = {
|
||||||
'status': 'pass'
|
'status': 'pass'
|
||||||
}
|
}
|
||||||
|
files = json.loads(request.POST.get("ids", "[]"))
|
||||||
|
for f in files:
|
||||||
|
try:
|
||||||
|
fil = File.objects.get(pk=f)
|
||||||
|
if fil.can_edit(request.user):
|
||||||
|
fil.delete()
|
||||||
|
else:
|
||||||
|
response['status'] = 'fail'
|
||||||
|
response['error'] = 'you do not have permissions to delete these files'
|
||||||
|
except:
|
||||||
|
response['status'] = 'fail'
|
||||||
|
response['error'] = "oops, looks like someone may have deleted the file already..."
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user