diff --git a/draw/consumers.py b/draw/consumers.py index 23384d6..4dd90e5 100644 --- a/draw/consumers.py +++ b/draw/consumers.py @@ -430,24 +430,27 @@ class DrawConsumer(AsyncJsonWebsocketConsumer): # This also determines the passage order, in the natural order this time. # If there is a 5-teams pool, we force the last team to be in the first pool, # which is this specific pool since they are ordered by decreasing size. - tds_copy = tds.copy() - round2 = await self.tournament.draw.round_set.filter(number=2).aget() - round2_pools = [p async for p in Pool.objects.filter(round__draw__tournament=self.tournament, round=round2) - .order_by('letter').all()] - current_pool_id, current_passage_index = 0, 0 - for i, td in enumerate(tds_copy): - if i == len(tds) - 1 and round2_pools[0].size == 5: - current_pool_id = 0 - current_passage_index = 4 + # This is not true for the final tournament, which considers the scores of the + # first round. + if not self.tournament.final: + tds_copy = tds.copy() + round2 = await self.tournament.draw.round_set.filter(number=2).aget() + round2_pools = [p async for p in Pool.objects.filter(round__draw__tournament=self.tournament, round=round2) + .order_by('letter').all()] + current_pool_id, current_passage_index = 0, 0 + for i, td in enumerate(tds_copy): + if i == len(tds) - 1 and round2_pools[0].size == 5: + current_pool_id = 0 + current_passage_index = 4 - td2 = await TeamDraw.objects.filter(participation=td.participation, round=round2).aget() - td2.pool = round2_pools[current_pool_id] - td2.passage_index = current_passage_index - current_pool_id += 1 - if current_pool_id == len(round2_pools): - current_pool_id = 0 - current_passage_index += 1 - await td2.asave() + td2 = await TeamDraw.objects.filter(participation=td.participation, round=round2).aget() + td2.pool = round2_pools[current_pool_id] + td2.passage_index = current_passage_index + current_pool_id += 1 + if current_pool_id == len(round2_pools): + current_pool_id = 0 + current_passage_index += 1 + await td2.asave() # The current pool is the first pool of the current (first) round pool = await Pool.objects.filter(round=self.tournament.draw.current_round, letter=1).aget() diff --git a/draw/templates/draw/tournament_content.html b/draw/templates/draw/tournament_content.html index 765a1d7..62d462a 100644 --- a/draw/templates/draw/tournament_content.html +++ b/draw/templates/draw/tournament_content.html @@ -351,7 +351,7 @@ {% trans "Are you sure you want to abort this draw?" %}