mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 03:02:14 +01:00 
			
		
		
		
	Fix permissions for final tournament
This commit is contained in:
		@@ -164,7 +164,9 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
 | 
				
			|||||||
        if user.registration.is_admin or user.registration.participates and \
 | 
					        if user.registration.is_admin or user.registration.participates and \
 | 
				
			||||||
                user.registration.team and user.registration.team.pk == kwargs["pk"] \
 | 
					                user.registration.team and user.registration.team.pk == kwargs["pk"] \
 | 
				
			||||||
                or user.registration.is_volunteer \
 | 
					                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)
 | 
					            return super().get(request, *args, **kwargs)
 | 
				
			||||||
        raise PermissionDenied
 | 
					        raise PermissionDenied
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -292,7 +294,9 @@ class TeamUpdateView(LoginRequiredMixin, UpdateView):
 | 
				
			|||||||
        if user.registration.is_admin or user.registration.participates and \
 | 
					        if user.registration.is_admin or user.registration.participates and \
 | 
				
			||||||
                user.registration.team and user.registration.team.pk == kwargs["pk"] \
 | 
					                user.registration.team and user.registration.team.pk == kwargs["pk"] \
 | 
				
			||||||
                or user.registration.is_volunteer \
 | 
					                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)
 | 
					            return super().dispatch(request, *args, **kwargs)
 | 
				
			||||||
        raise PermissionDenied
 | 
					        raise PermissionDenied
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -373,7 +377,9 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView):
 | 
				
			|||||||
        if not user.is_authenticated:
 | 
					        if not user.is_authenticated:
 | 
				
			||||||
            return super().handle_no_permission()
 | 
					            return super().handle_no_permission()
 | 
				
			||||||
        if user.registration.is_admin or user.registration.is_volunteer \
 | 
					        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)
 | 
					            return super().dispatch(request, *args, **kwargs)
 | 
				
			||||||
        raise PermissionDenied
 | 
					        raise PermissionDenied
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -479,7 +485,9 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
 | 
				
			|||||||
                and user.registration.team.participation \
 | 
					                and user.registration.team.participation \
 | 
				
			||||||
                and user.registration.team.participation.pk == kwargs["pk"] \
 | 
					                and user.registration.team.participation.pk == kwargs["pk"] \
 | 
				
			||||||
                or user.registration.is_volunteer \
 | 
					                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)
 | 
					            return super().dispatch(request, *args, **kwargs)
 | 
				
			||||||
        raise PermissionDenied
 | 
					        raise PermissionDenied
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -242,7 +242,9 @@ class UserDetailView(LoginRequiredMixin, DetailView):
 | 
				
			|||||||
        user = self.get_object()
 | 
					        user = self.get_object()
 | 
				
			||||||
        if user == me or me.registration.is_admin or me.registration.is_volunteer \
 | 
					        if user == me or me.registration.is_admin or me.registration.is_volunteer \
 | 
				
			||||||
                and user.registration.participates and user.registration.team \
 | 
					                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 \
 | 
					                or user.registration.is_volunteer and me.registration.is_volunteer \
 | 
				
			||||||
                and me.registration.interesting_tournaments.intersection(user.registration.interesting_tournaments):
 | 
					                and me.registration.interesting_tournaments.intersection(user.registration.interesting_tournaments):
 | 
				
			||||||
            return super().dispatch(request, *args, **kwargs)
 | 
					            return super().dispatch(request, *args, **kwargs)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user