mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 09:02:11 +01:00 
			
		
		
		
	Prevent some errors
This commit is contained in:
		@@ -1628,7 +1628,7 @@ class Pool(models.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def update_juries_lines_spreadsheet(self):
 | 
					    def update_juries_lines_spreadsheet(self):
 | 
				
			||||||
        if not self.participations.count() or not self.passages.count():
 | 
					        if not self.participations.count() or not self.passages.count():
 | 
				
			||||||
            # Not initialized yet
 | 
					            # Not initialized yet
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
					        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -557,7 +557,7 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
 | 
				
			|||||||
        if not self.get_object().valid:
 | 
					        if not self.get_object().valid:
 | 
				
			||||||
            raise PermissionDenied(_("The team is not validated yet."))
 | 
					            raise PermissionDenied(_("The team is not validated yet."))
 | 
				
			||||||
        if user.registration.is_admin or user.registration.participates \
 | 
					        if user.registration.is_admin or user.registration.participates \
 | 
				
			||||||
                and user.registration.team.participation \
 | 
					                and user.registration.team \
 | 
				
			||||||
                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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -726,10 +726,11 @@ class PhotoAuthorizationView(LoginRequiredMixin, View):
 | 
				
			|||||||
    def get(self, request, *args, **kwargs):
 | 
					    def get(self, request, *args, **kwargs):
 | 
				
			||||||
        filename = kwargs["filename"]
 | 
					        filename = kwargs["filename"]
 | 
				
			||||||
        path = f"media/authorization/photo/{filename}"
 | 
					        path = f"media/authorization/photo/{filename}"
 | 
				
			||||||
        if not os.path.exists(path):
 | 
					        student_qs = ParticipantRegistration.objects.filter(Q(photo_authorization__endswith=filename)
 | 
				
			||||||
            raise Http404
 | 
					 | 
				
			||||||
        student = ParticipantRegistration.objects.get(Q(photo_authorization__endswith=filename)
 | 
					 | 
				
			||||||
                                                            | Q(photo_authorization_final__endswith=filename))
 | 
					                                                            | Q(photo_authorization_final__endswith=filename))
 | 
				
			||||||
 | 
					        if not os.path.exists(path) or not student_qs.exists():
 | 
				
			||||||
 | 
					            raise Http404
 | 
				
			||||||
 | 
					        student = student_qs.get()
 | 
				
			||||||
        user = request.user
 | 
					        user = request.user
 | 
				
			||||||
        if not (student.user == user or user.registration.is_admin or user.registration.is_volunteer and student.team
 | 
					        if not (student.user == user or user.registration.is_admin or user.registration.is_volunteer and student.team
 | 
				
			||||||
                and student.team.participation.tournament in user.registration.organized_tournaments.all()):
 | 
					                and student.team.participation.tournament in user.registration.organized_tournaments.all()):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user