From 13414ee0c50760d76c667ebf454258d6272331ef Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 18 Mar 2021 18:22:17 +0100 Subject: [PATCH] Organizers can upload documents for team members --- tfjm/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tfjm/views.py b/tfjm/views.py index 39bca65..6ccea34 100644 --- a/tfjm/views.py +++ b/tfjm/views.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.contrib.auth.mixins import LoginRequiredMixin +from django.contrib.auth.models import User from haystack.generic_views import SearchView @@ -30,7 +31,11 @@ class UserMixin(LoginRequiredMixin): class UserRegistrationMixin(LoginRequiredMixin): def dispatch(self, request, *args, **kwargs): user = request.user - if user.is_authenticated and not user.registration.is_admin and user.registration.pk != kwargs["pk"]: + user_object = User.objects.get(registration__pk=kwargs["pk"]) + if user.is_authenticated and not user.registration.is_admin and user.registration.pk != kwargs["pk"] and \ + not (user.registration.is_volunteer and user_object.registration.team is not None + and user_object.registration.team.participation.tournament + in user.registration.organized_tournaments.all()): self.handle_no_permission() return super().dispatch(request, *args, **kwargs)