Skip to content

Commit 699da05

Browse files
committed
make sure authority and section exist on marking page
1 parent d19b35e commit 699da05

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crowdsourcer/views/base.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.db.models.functions import Cast
1111
from django.dispatch import receiver
1212
from django.http import JsonResponse
13+
from django.shortcuts import get_object_or_404
1314
from django.views.generic import ListView, TemplateView
1415

1516
from crowdsourcer.forms import ResponseForm, ResponseFormset
@@ -97,10 +98,14 @@ def add_previous(self, initial, rt):
9798
return initial
9899

99100
def get_initial_obj(self):
100-
self.authority = PublicAuthority.objects.get(name=self.kwargs["name"])
101+
self.authority = get_object_or_404(PublicAuthority, name=self.kwargs["name"])
102+
section = get_object_or_404(
103+
Section,
104+
title=self.kwargs["section_title"],
105+
marking_session=self.request.current_session,
106+
)
101107
self.questions = Question.objects.filter(
102-
section__marking_session=self.request.current_session,
103-
section__title=self.kwargs["section_title"],
108+
section=section,
104109
questiongroup=self.authority.questiongroup,
105110
how_marked__in=self.how_marked_in,
106111
).order_by("number", "number_part")

0 commit comments

Comments
 (0)