1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-09-12 04:07:03 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Emmy D'Anello
a381b5583c Fix permissions for solutions and syntheses
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-03 22:23:36 +02:00
Emmy D'Anello
867ee7efe1 Fix passage view for participants
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-03 22:22:16 +02:00
Emmy D'Anello
32b2d7239c Fix important information for participants
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-03 22:19:09 +02:00
3 changed files with 23 additions and 22 deletions

View File

@@ -750,19 +750,19 @@ class Participation(models.Model):
draw_url = reverse_lazy("draw:index") draw_url = reverse_lazy("draw:index")
solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,)) solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,))
defender_content = format_lazy(defender_text, draw_url=draw_url, defender_content = format_lazy(defender_text, draw_url=draw_url,
solution_url=solution_url, problem=defender_passage.problem) solution_url=solution_url, problem=defender_passage.solution_number)
opponent_text = _("<p>You will oppose the solution of the team {opponent} on the problem {problem}. " opponent_text = _("<p>You will oppose the solution of the team {opponent} on the problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,))
opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram, opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram,
problem=opponent_passage.problem, passage_url=passage_url) problem=opponent_passage.solution_number, passage_url=passage_url)
reporter_text = _("<p>You will report the solution of the team {reporter} on the problem {problem}. " reporter_text = _("<p>You will report the solution of the team {reporter} on the problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,))
reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram, reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram,
problem=reporter_passage.problem, passage_url=passage_url) problem=reporter_passage.solution_number, passage_url=passage_url)
content = defender_content + opponent_content + reporter_content content = defender_content + opponent_content + reporter_content
informations.append({ informations.append({
@@ -782,19 +782,19 @@ class Participation(models.Model):
draw_url = reverse_lazy("draw:index") draw_url = reverse_lazy("draw:index")
solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,)) solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,))
defender_content = format_lazy(defender_text, draw_url=draw_url, defender_content = format_lazy(defender_text, draw_url=draw_url,
solution_url=solution_url, problem=defender_passage.problem) solution_url=solution_url, problem=defender_passage.solution_number)
opponent_text = _("<p>You will oppose the solution of the team {opponent} on the problem {problem}. " opponent_text = _("<p>You will oppose the solution of the team {opponent} on the problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,))
opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram, opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram,
problem=opponent_passage.problem, passage_url=passage_url) problem=opponent_passage.solution_number, passage_url=passage_url)
reporter_text = _("<p>You will report the solution of the team {reporter} on the problem {problem}. " reporter_text = _("<p>You will report the solution of the team {reporter} on the problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,))
reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram, reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram,
problem=reporter_passage.problem, passage_url=passage_url) problem=reporter_passage.solution_number, passage_url=passage_url)
content = defender_content + opponent_content + reporter_content content = defender_content + opponent_content + reporter_content
informations.append({ informations.append({

View File

@@ -1894,30 +1894,31 @@ class PassageDetailView(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
reg = self.request.user.registration reg = self.request.user.registration
if reg in self.object.pool.juries.all(): passage = self.object
context["my_note"] = Note.objects.get_or_create(passage=self.object, jury=self.request.user.registration)[0] if reg in passage.pool.juries.all():
context["my_note"] = Note.objects.get_or_create(passage=passage, jury=self.request.user.registration)[0]
if reg.is_volunteer: if reg.is_volunteer:
notes = self.object.notes.all() notes = passage.notes.all()
if not reg.is_admin \ if not reg.is_admin \
and (reg != self.object.pool.jury_president and (reg != passage.pool.jury_president
or reg not in self.object.pool.tournament.organizers.all()): or reg not in passage.pool.tournament.organizers.all()):
notes = [note for note in notes if note.has_any_note() or note.jury == reg] notes = [note for note in notes if note.has_any_note() or note.jury == reg]
context["notes"] = NoteTable(notes) context["notes"] = NoteTable(notes)
# Only display the observer column for 4-teams pools # Only display the observer column for 4-teams pools
if self.object.pool.participations.count() != 4: if passage.pool.participations.count() != 4:
context['notes']._sequence.remove('observer_oral') context['notes']._sequence.remove('observer_oral')
if 'notes' in context and not self.request.user.registration.is_admin: if 'notes' in context and not self.request.user.registration.is_admin:
context['notes']._sequence.remove('update') context['notes']._sequence.remove('update')
context['notes'].columns['defender_writing'].column.verbose_name += f" ({self.object.defender.team.trigram})" context['notes'].columns['defender_writing'].column.verbose_name += f" ({passage.defender.team.trigram})"
context['notes'].columns['defender_oral'].column.verbose_name += f" ({self.object.defender.team.trigram})" context['notes'].columns['defender_oral'].column.verbose_name += f" ({passage.defender.team.trigram})"
context['notes'].columns['opponent_writing'].column.verbose_name += f" ({self.object.opponent.team.trigram})" context['notes'].columns['opponent_writing'].column.verbose_name += f" ({passage.opponent.team.trigram})"
context['notes'].columns['opponent_oral'].column.verbose_name += f" ({self.object.opponent.team.trigram})" context['notes'].columns['opponent_oral'].column.verbose_name += f" ({passage.opponent.team.trigram})"
context['notes'].columns['reporter_writing'].column.verbose_name += f" ({self.object.reporter.team.trigram})" context['notes'].columns['reporter_writing'].column.verbose_name += f" ({passage.reporter.team.trigram})"
context['notes'].columns['reporter_oral'].column.verbose_name += f" ({self.object.reporter.team.trigram})" context['notes'].columns['reporter_oral'].column.verbose_name += f" ({passage.reporter.team.trigram})"
if self.object.observer: if self.object.observer:
context['notes'].columns['observer_oral'].column.verbose_name += f" ({self.object.observer.team.trigram})" context['notes'].columns['observer_oral'].column.verbose_name += f" ({passage.observer.team.trigram})"
return context return context

View File

@@ -800,7 +800,7 @@ class SolutionView(LoginRequiredMixin, View):
or (user.registration.is_volunteer or (user.registration.is_volunteer
and user.registration in solution.tournament.organizers.all()) and user.registration in solution.tournament.organizers.all())
or (user.registration.is_volunteer or (user.registration.is_volunteer
and user.registration.presided_pools.filter(tournament=solution.tournament).exists()) and user.registration.pools_presided.filter(tournament=solution.tournament).exists())
or user.registration.is_volunteer or user.registration.is_volunteer
and Passage.objects.filter(Q(pool__juries=user.registration) and Passage.objects.filter(Q(pool__juries=user.registration)
| Q(pool__tournament__in=user.registration.organized_tournaments.all()), | Q(pool__tournament__in=user.registration.organized_tournaments.all()),
@@ -836,7 +836,7 @@ class SynthesisView(LoginRequiredMixin, View):
if not (user.registration.is_admin or user.registration.is_volunteer if not (user.registration.is_admin or user.registration.is_volunteer
and (user.registration in synthesis.passage.pool.juries.all() and (user.registration in synthesis.passage.pool.juries.all()
or user.registration in synthesis.passage.pool.tournament.organizers.all() or user.registration in synthesis.passage.pool.tournament.organizers.all()
or user.registration.presided_pools.filter(tournament=synthesis.passage.pool.tournament).exists()) or user.registration.pools_presided.filter(tournament=synthesis.passage.pool.tournament).exists())
or user.registration.participates and user.registration.team == synthesis.participation.team): or user.registration.participates and user.registration.team == synthesis.participation.team):
raise PermissionDenied raise PermissionDenied
# Guess mime type of the file # Guess mime type of the file