Skip to content

Commit

Permalink
Check missing exam date and wrong format exam date seperatly
Browse files Browse the repository at this point in the history
  • Loading branch information
FSadrieh committed Nov 11, 2024
1 parent 57bdab1 commit 1fa2870
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions evap/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,14 @@ def create_exam_evaluation(request: HttpRequest) -> HttpResponse:

if evaluation.has_exam_evaluation:
raise SuspiciousOperation("An exam evaluation already exists for this course")

exam_date = request.POST.get("exam_date")
if not exam_date:
return HttpResponseBadRequest("Exam date missing.")
try:
exam_date = request.POST.get("exam_date")
exam_date = datetime.strptime(exam_date, "%Y-%m-%d").date()
except TypeError:
return HttpResponseBadRequest("Exam date missing or invalid.")
except ValueError:
return HttpResponseBadRequest("Exam date invalid.")

if exam_date < evaluation.earliest_possible_exam_date:
raise SuspiciousOperation(
Expand Down

0 comments on commit 1fa2870

Please sign in to comment.