From 97f2f6279f9fea8e86e8cd9cf2934cb7625388ab Mon Sep 17 00:00:00 2001 From: amickan Date: Wed, 18 Dec 2024 16:18:03 +0100 Subject: [PATCH] Update JobCreatePermissionMixin to use AccessMixin --- app/grandchallenge/algorithms/views.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/grandchallenge/algorithms/views.py b/app/grandchallenge/algorithms/views.py index e2574413d..596ed8039 100644 --- a/app/grandchallenge/algorithms/views.py +++ b/app/grandchallenge/algorithms/views.py @@ -480,19 +480,18 @@ def get_success_url(self): class JobCreatePermissionMixin( - LoginRequiredMixin, - ObjectPermissionRequiredMixin, - VerificationRequiredMixin, + LoginRequiredMixin, VerificationRequiredMixin, AccessMixin ): - permission_required = "algorithms.execute_algorithm" - raise_exception = True - @cached_property def algorithm(self) -> Algorithm: return get_object_or_404(Algorithm, slug=self.kwargs["slug"]) - def get_permission_object(self): - return self.algorithm + def dispatch(self, request, *args, **kwargs): + if not request.user.has_perm( + "algorithms.execute_algorithm", self.algorithm + ): + return self.handle_no_permission() + return super().dispatch(request, *args, **kwargs) class JobInterfaceSelect(