1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 14:38:24 +02:00

Defender => Reporter

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-07-06 22:12:07 +02:00
parent 12205f953b
commit 620bbe7817
19 changed files with 481 additions and 287 deletions

View File

@ -837,11 +837,11 @@ class SolutionView(LoginRequiredMixin, View):
solution = Solution.objects.get(file__endswith=filename)
user = request.user
if user.registration.participates and user.registration.team.participation:
passage_participant_qs = Passage.objects.filter(Q(defender=user.registration.team.participation)
passage_participant_qs = Passage.objects.filter(Q(reporter=user.registration.team.participation)
| Q(opponent=user.registration.team.participation)
| Q(reviewer=user.registration.team.participation)
| Q(observer=user.registration.team.participation),
defender=solution.participation,
reporter=solution.participation,
solution_number=solution.problem)
else:
passage_participant_qs = Passage.objects.none()
@ -853,7 +853,7 @@ class SolutionView(LoginRequiredMixin, View):
or user.registration.is_volunteer
and Passage.objects.filter(Q(pool__juries=user.registration)
| Q(pool__tournament__in=user.registration.organized_tournaments.all()),
defender=solution.participation,
reporter=solution.participation,
solution_number=solution.problem).exists()
or user.registration.participates and user.registration.team
and (solution.participation.team == user.registration.team or
@ -881,20 +881,20 @@ class WrittenReviewView(LoginRequiredMixin, View):
path = f"media/reviews/{filename}"
if not os.path.exists(path):
raise Http404
reviews = WrittenReview.objects.get(file__endswith=filename)
review = WrittenReview.objects.get(file__endswith=filename)
user = request.user
if not (user.registration.is_admin or user.registration.is_volunteer
and (user.registration in reviews.passage.pool.juries.all()
or user.registration in reviews.passage.pool.tournament.organizers.all()
or user.registration.pools_presided.filter(tournament=reviews.passage.pool.tournament).exists())
or user.registration.participates and user.registration.team == reviews.participation.team):
and (user.registration in review.passage.pool.juries.all()
or user.registration in review.passage.pool.tournament.organizers.all()
or user.registration.pools_presided.filter(tournament=review.passage.pool.tournament).exists())
or user.registration.participates and user.registration.team == review.participation.team):
raise PermissionDenied
# Guess mime type of the file
mime = Magic(mime=True)
mime_type = mime.from_file(path)
ext = mime_type.split("/")[1].replace("jpeg", "jpg")
# Replace file name
true_file_name = str(reviews) + f".{ext}"
true_file_name = str(review) + f".{ext}"
return FileResponse(open(path, "rb"), content_type=mime_type, filename=true_file_name)