fix move, note to self: understand decorators :(

This commit is contained in:
Sanj 2011-07-05 14:18:42 +05:30
parent 0c33ce46de
commit 6ecf5ee3c6

View File

@ -314,15 +314,18 @@ def makeFilePublic(request):
@csrf_exempt @csrf_exempt
@user_passes_test_json(canEditFiles) # @user_passes_test_json(canEditFiles)
@login_required
def moveFiles(request): def moveFiles(request):
response = {} response = {}
user = request.user
files = json.loads(request.POST.get("ids", "[]")) files = json.loads(request.POST.get("ids", "[]"))
study_id = int(request.POST.get("study", "0")) study_id = int(request.POST.get("study", "0"))
study = Category.objects.get(pk=study_id) study = Category.objects.get(pk=study_id)
for f in files: for f in files:
fil = File.objects.get(pk=f) fil = File.objects.get(pk=f)
fil.move_to(study) if fil.can_edit(user):
fil.move_to(study)
response['status'] = 'pass' response['status'] = 'pass'
return render_to_json_response(errors) return render_to_json_response(errors)