1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-08-16 05:30:01 +02:00

Compare commits

..

4 Commits

Author SHA1 Message Date
Yohann D'ANELLO
9c4e68d0ea Merge branch 'dev' into 'master'
Permissions on user detail

See merge request animath/si/plateforme-tfjm!15
2021-01-29 09:36:53 +00:00
2367131316 Raise error when a given tournament does not exist 2021-01-29 10:33:06 +01:00
67540df334 Fix error message when a tournament is not specified 2021-01-29 10:31:30 +01:00
a6000aec2a Fix permission to view user detail 2021-01-29 10:24:00 +01:00

View File

@@ -242,7 +242,7 @@ 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 user.registration.organized_tournaments.all() \
and user.registration.team.participation.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.intersting_tournaments):
return super().dispatch(request, *args, **kwargs)
@@ -376,10 +376,12 @@ class AuthorizationTemplateView(TemplateView):
if registration.user == self.request.user \
or self.request.user.is_authenticated and self.request.user.registration.is_admin:
context["registration"] = registration
if "tournament_id" in self.request.GET:
if "tournament_id" in self.request.GET and self.request.GET.get("tournament_id").isnumeric():
if not Tournament.objects.filter(pk=self.request.get("tournament_id")).exists():
raise PermissionDenied("Ce tournoi n'existe pas.")
context["tournament"] = Tournament.objects.get(pk=self.request.GET.get("tournament_id"))
else:
raise ValueError("Merci d'indiquer un tournoi.")
raise PermissionDenied("Merci d'indiquer un tournoi.")
return context