Merge pull request #128 from danieldupriest/user_check_final
added conditional to check user in finalize_report()
This commit is contained in:
commit
5259738a3d
1 changed files with 4 additions and 0 deletions
|
@ -242,6 +242,10 @@ def finalize_report(request, report_pk):
|
||||||
:param report_pk: report ID
|
:param report_pk: report ID
|
||||||
:return: JSON response containing user message
|
:return: JSON response containing user message
|
||||||
"""
|
"""
|
||||||
|
# Check that the user owns the report
|
||||||
|
if not user_owns_report(user=request.user, report=report_pk):
|
||||||
|
return JsonResponse({"message": "Current user does not own the specified report."}, status=401)
|
||||||
|
|
||||||
r = Report.objects.get(id=report_pk)
|
r = Report.objects.get(id=report_pk)
|
||||||
if r.submitted:
|
if r.submitted:
|
||||||
return JsonResponse({"message": "Cannot submit a report that has already been submitted."}, status=409)
|
return JsonResponse({"message": "Cannot submit a report that has already been submitted."}, status=409)
|
||||||
|
|
Loading…
Reference in a new issue