Fix the transition between the two rounds
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
b3c26b8c1c
commit
b0a248e81a
|
@ -171,11 +171,14 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
participation = await Participation.objects\
|
participation = await Participation.objects\
|
||||||
.filter(teamdraw__round=self.tournament.draw.current_round,
|
.filter(teamdraw__round=self.tournament.draw.current_round,
|
||||||
teamdraw__passage_dice__isnull=True).prefetch_related('team').afirst()
|
teamdraw__passage_dice__isnull=True).prefetch_related('team').afirst()
|
||||||
trigram = participation.team.trigram
|
|
||||||
else:
|
else:
|
||||||
participation = await Participation.objects.filter(team__participants=self.registration)\
|
participation = await Participation.objects.filter(team__participants=self.registration)\
|
||||||
.prefetch_related('team').aget()
|
.prefetch_related('team').aget()
|
||||||
trigram = participation.team.trigram
|
|
||||||
|
if participation is None:
|
||||||
|
return await self.alert(_("This is not the time for this."), 'danger')
|
||||||
|
|
||||||
|
trigram = participation.team.trigram
|
||||||
|
|
||||||
team_draw = await TeamDraw.objects.filter(participation=participation,
|
team_draw = await TeamDraw.objects.filter(participation=participation,
|
||||||
round_id=self.tournament.draw.current_round_id).aget()
|
round_id=self.tournament.draw.current_round_id).aget()
|
||||||
|
@ -293,12 +296,13 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
||||||
{'type': 'draw.dice_visibility', 'visible': True})
|
{'type': 'draw.dice_visibility', 'visible': True})
|
||||||
|
|
||||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
# First send the second pool to have the good team order
|
||||||
{'type': 'draw.send_poules',
|
|
||||||
'round': self.tournament.draw.current_round})
|
|
||||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
{'type': 'draw.send_poules',
|
{'type': 'draw.send_poules',
|
||||||
'round': await self.tournament.draw.round_set.filter(number=2).aget()})
|
'round': await self.tournament.draw.round_set.filter(number=2).aget()})
|
||||||
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
|
{'type': 'draw.send_poules',
|
||||||
|
'round': self.tournament.draw.current_round})
|
||||||
|
|
||||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
{'type': 'draw.set_info', 'draw': self.tournament.draw})
|
{'type': 'draw.set_info', 'draw': self.tournament.draw})
|
||||||
|
@ -518,7 +522,19 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
f"tournament-{self.tournament.id}",
|
f"tournament-{self.tournament.id}",
|
||||||
{'type': 'draw.dice', 'team': participation.team.trigram, 'result': None})
|
{'type': 'draw.dice', 'team': participation.team.trigram, 'result': None})
|
||||||
|
|
||||||
await self.channel_layer.group_send(f"team-{participation.team.trigram}",
|
# Reorder dices
|
||||||
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
|
{'type': 'draw.send_poules',
|
||||||
|
'round': r2})
|
||||||
|
|
||||||
|
# The passage order for the second round is already determined by the first round
|
||||||
|
# Start the first pool of the second round
|
||||||
|
p1: Pool = await r2.pool_set.filter(letter=1).aget()
|
||||||
|
r2.current_pool = p1
|
||||||
|
await sync_to_async(r2.save)()
|
||||||
|
|
||||||
|
async for td in p1.teamdraw_set.prefetch_related('participation__team').all():
|
||||||
|
await self.channel_layer.group_send(f"team-{td.participation.team.trigram}",
|
||||||
{'type': 'draw.dice_visibility', 'visible': True})
|
{'type': 'draw.dice_visibility', 'visible': True})
|
||||||
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
||||||
{'type': 'draw.dice_visibility', 'visible': True})
|
{'type': 'draw.dice_visibility', 'visible': True})
|
||||||
|
|
Loading…
Reference in New Issue