1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 17:42:23 +00:00

Fix passage view for participants

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-03 22:22:16 +02:00
parent 32b2d7239c
commit 867ee7efe1
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

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