From d19b35e425ff664935fbc09845e4446e9c5e7eeb Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 19 Dec 2024 09:52:39 +0000 Subject: [PATCH] raise a 404 if the marking session name is bad --- crowdsourcer/middleware.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crowdsourcer/middleware.py b/crowdsourcer/middleware.py index a66db83..4425ff6 100644 --- a/crowdsourcer/middleware.py +++ b/crowdsourcer/middleware.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.http import Http404 from crowdsourcer.models import MarkingSession, ResponseType @@ -21,6 +22,8 @@ def process_view(self, request, view_func, view_args, view_kwargs): current_session = MarkingSession.objects.filter( label=session_name, active=True ).first() + if current_session is None: + raise Http404 else: current_session = ( MarkingSession.objects.filter(active=True).order_by("-default").first()