From 9ad71174b6c2f9483acf1629f3bb7b3e60cb7a47 Mon Sep 17 00:00:00 2001 From: James Meakin <12661555+jmsmkn@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:33:20 +0100 Subject: [PATCH] Fix Phase lookups --- app/grandchallenge/evaluation/views/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/grandchallenge/evaluation/views/__init__.py b/app/grandchallenge/evaluation/views/__init__.py index c9df0b19a..dbb94d17c 100644 --- a/app/grandchallenge/evaluation/views/__init__.py +++ b/app/grandchallenge/evaluation/views/__init__.py @@ -208,8 +208,8 @@ class PhaseUpdate( queryset = Phase.objects.prefetch_related("optional_hanging_protocols") def get_object(self, queryset=None): - return Phase.objects.get( - challenge=self.request.challenge, slug=self.kwargs["slug"] + return get_object_or_404( + Phase, challenge=self.request.challenge, slug=self.kwargs["slug"] ) def get_form_kwargs(self): @@ -325,8 +325,8 @@ def get_permission_object(self): @cached_property def phase(self): - return Phase.objects.get( - challenge=self.request.challenge, slug=self.kwargs["slug"] + return get_object_or_404( + Phase, challenge=self.request.challenge, slug=self.kwargs["slug"] ) def get_form_kwargs(self): @@ -868,8 +868,8 @@ def form_valid(self, form): @cached_property def phase(self): - return Phase.objects.get( - slug=self.kwargs["slug"], challenge=self.request.challenge + return get_object_or_404( + Phase, slug=self.kwargs["slug"], challenge=self.request.challenge ) def get_success_url(self):