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 4, 2024
1 parent 5fbd07e commit 064dec9
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.")

Check warning on line 1112 in evap/staff/views.py

View check run for this annotation

Codecov / codecov/patch

evap/staff/views.py#L1111-L1112

Added lines #L1111 - L1112 were not covered by tests

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

0 comments on commit 064dec9

Please sign in to comment.