Skip to content

Commit

Permalink
Merge pull request #83 from swecc-uw/fix-report-status
Browse files Browse the repository at this point in the history
Fix issue in validating report statuses
  • Loading branch information
Advayp authored Dec 29, 2024
2 parents b7e1b16 + dacfc12 commit 0ca5ee4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/report/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ def patch(self, request, report_id):
{"error": "status is required"}, status=status.HTTP_400_BAD_REQUEST
)

if request.data["status"] not in Report.STATUS_CHOICES:
updated_status = request.data["status"]

if not any(
updated_status in valid_choice for valid_choice in Report.STATUS_CHOICES
):
return Response(
{"error": "Invalid status provided"}, status=status.HTTP_400_BAD_REQUEST
)

report = report[0]
report.status = request.data["status"]
report.status = updated_status
report.save()

return Response(
Expand Down

0 comments on commit 0ca5ee4

Please sign in to comment.