1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-26 07:02:24 +00:00

Only harmonize valid participations

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-31 22:12:54 +02:00
parent bb579d640c
commit 10a42d3633
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -742,7 +742,7 @@ class TournamentHarmonizeView(VolunteerMixin, DetailView):
.format(tournament=tournament, round=context["round"]) .format(tournament=tournament, round=context["round"])
notes = dict() notes = dict()
for participation in self.object.participations.all(): for participation in self.object.participations.filter(valid=True).all():
note = sum(pool.average(participation) for pool in context['pools']) note = sum(pool.average(participation) for pool in context['pools'])
tweak = sum(tweak.diff for tweak in participation.tweaks.filter(pool__in=context['pools']).all()) tweak = sum(tweak.diff for tweak in participation.tweaks.filter(pool__in=context['pools']).all())
notes[participation] = {'note': note, 'tweak': tweak} notes[participation] = {'note': note, 'tweak': tweak}
@ -762,13 +762,14 @@ class TournamentHarmonizeNoteView(VolunteerMixin, DetailView):
if not reg.is_admin and (not reg.is_volunteer or tournament not in reg.organized_tournaments.all()): if not reg.is_admin and (not reg.is_volunteer or tournament not in reg.organized_tournaments.all()):
return self.handle_no_permission() return self.handle_no_permission()
if self.kwargs['round'] not in (1, 2) or self.kwargs['action'] not in ('add', 'remove') \ if self.kwargs['round'] not in (1, 2) or self.kwargs['action'] not in ('add', 'remove') \
or self.kwargs['trigram'] not in [p.team.trigram for p in tournament.participations.all()]: or self.kwargs['trigram'] not in [p.team.trigram
for p in tournament.participations.filter(valid=True).all()]:
raise Http404 raise Http404
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
tournament = self.get_object() tournament = self.get_object()
participation = tournament.participations.get(team__trigram=kwargs['trigram']) participation = tournament.participations.filter(valid=True).get(team__trigram=kwargs['trigram'])
pool = tournament.pools.get(round=kwargs['round'], participations=participation) pool = tournament.pools.get(round=kwargs['round'], participations=participation)
tweak_qs = Tweak.objects.filter(participation=participation, pool=pool) tweak_qs = Tweak.objects.filter(participation=participation, pool=pool)
old_diff = tweak_qs.first().diff if tweak_qs.exists() else 0 old_diff = tweak_qs.first().diff if tweak_qs.exists() else 0