1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 17:42:23 +00:00

Fix permissions for final tournament

This commit is contained in:
Yohann D'ANELLO 2021-05-11 16:40:18 +02:00
parent 9a1006b341
commit ba6a6338f5
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 15 additions and 5 deletions

View File

@ -164,7 +164,9 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
if user.registration.is_admin or user.registration.participates and \
user.registration.team and user.registration.team.pk == kwargs["pk"] \
or user.registration.is_volunteer \
and self.object.participation.tournament in user.registration.interesting_tournaments:
and (self.object.participation.tournament in user.registration.interesting_tournaments
or self.object.participation.final
and Tournament.final_tournament() in user.registration.interesting_tournaments):
return super().get(request, *args, **kwargs)
raise PermissionDenied
@ -292,7 +294,9 @@ class TeamUpdateView(LoginRequiredMixin, UpdateView):
if user.registration.is_admin or user.registration.participates and \
user.registration.team and user.registration.team.pk == kwargs["pk"] \
or user.registration.is_volunteer \
and self.get_object().participation.tournament in user.registration.interesting_tournaments:
and (self.get_object().participation.tournament in user.registration.interesting_tournaments
or self.get_object().participation.final
and Tournament.final_tournament() in user.registration.interesting_tournaments):
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied
@ -373,7 +377,9 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView):
if not user.is_authenticated:
return super().handle_no_permission()
if user.registration.is_admin or user.registration.is_volunteer \
and self.get_object().participation.tournament in user.registration.interesting_tournaments:
and (self.get_object().participation.tournament in user.registration.interesting_tournaments
or self.get_object().participation.final
and Tournament.final_tournament() in user.registration.interesting_tournaments):
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied
@ -479,7 +485,9 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
and user.registration.team.participation \
and user.registration.team.participation.pk == kwargs["pk"] \
or user.registration.is_volunteer \
and self.get_object().tournament in user.registration.interesting_tournaments:
and (self.get_object().tournament in user.registration.interesting_tournaments
or self.get_object().final
and Tournament.final_tournament() in user.registration.interesting_tournaments):
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied

View File

@ -242,7 +242,9 @@ class UserDetailView(LoginRequiredMixin, DetailView):
user = self.get_object()
if user == me or me.registration.is_admin or me.registration.is_volunteer \
and user.registration.participates and user.registration.team \
and user.registration.team.participation.tournament in me.registration.organized_tournaments.all() \
and (user.registration.team.participation.tournament in me.registration.organized_tournaments.all()
or user.registration.team.participation.final
and Tournament.final_tournament() in me.registration.organized_tournaments.all()) \
or user.registration.is_volunteer and me.registration.is_volunteer \
and me.registration.interesting_tournaments.intersection(user.registration.interesting_tournaments):
return super().dispatch(request, *args, **kwargs)