Organizers can upload documents for team members

This commit is contained in:
Yohann D'ANELLO 2021-03-18 18:22:17 +01:00
parent cdacbe2ea1
commit 13414ee0c5
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 1 deletions

View File

@ -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)