Skip to content

Commit

Permalink
make sure authority and section exist on marking page
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Dec 19, 2024
1 parent d19b35e commit 699da05
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crowdsourcer/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.db.models.functions import Cast
from django.dispatch import receiver
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from django.views.generic import ListView, TemplateView

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

def get_initial_obj(self):
self.authority = PublicAuthority.objects.get(name=self.kwargs["name"])
self.authority = get_object_or_404(PublicAuthority, name=self.kwargs["name"])
section = get_object_or_404(
Section,
title=self.kwargs["section_title"],
marking_session=self.request.current_session,
)
self.questions = Question.objects.filter(
section__marking_session=self.request.current_session,
section__title=self.kwargs["section_title"],
section=section,
questiongroup=self.authority.questiongroup,
how_marked__in=self.how_marked_in,
).order_by("number", "number_part")
Expand Down

0 comments on commit 699da05

Please sign in to comment.