Fix undo draw step
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
2c4de8cec3
commit
338f0d456a
|
@ -1388,7 +1388,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
'round': r.number,
|
'round': r.number,
|
||||||
'team': td.participation.team.trigram,
|
'team': td.participation.team.trigram,
|
||||||
'problem': td.accepted})
|
'problem': td.accepted})
|
||||||
elif r.number >= 2:
|
elif r.number >= 2 and settings.TFJM_APP == "TFJM":
|
||||||
if not self.tournament.final:
|
if not self.tournament.final:
|
||||||
# Go to the previous round
|
# Go to the previous round
|
||||||
previous_round = await self.tournament.draw.round_set \
|
previous_round = await self.tournament.draw.round_set \
|
||||||
|
@ -1402,21 +1402,6 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
'team': td.participation.team.trigram,
|
'team': td.participation.team.trigram,
|
||||||
'result': td.choice_dice})
|
'result': td.choice_dice})
|
||||||
|
|
||||||
await self.channel_layer.group_send(
|
|
||||||
f"tournament-{self.tournament.id}",
|
|
||||||
{
|
|
||||||
'tid': self.tournament_id,
|
|
||||||
'type': 'draw.send_poules',
|
|
||||||
'round': previous_round.number,
|
|
||||||
'poules': [
|
|
||||||
{
|
|
||||||
'letter': pool.get_letter_display(),
|
|
||||||
'teams': await pool.atrigrams(),
|
|
||||||
}
|
|
||||||
async for pool in previous_round.pool_set.order_by('letter').all()
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
previous_pool = previous_round.current_pool
|
previous_pool = previous_round.current_pool
|
||||||
|
|
||||||
td = previous_pool.current_team
|
td = previous_pool.current_team
|
||||||
|
@ -1480,8 +1465,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
'visible': True})
|
'visible': True})
|
||||||
else:
|
else:
|
||||||
# Go to the dice order
|
# Go to the dice order
|
||||||
async for r0 in self.tournament.draw.round_set.all():
|
async for td in r.teamdraw_set.all():
|
||||||
async for td in r0.teamdraw_set.all():
|
|
||||||
td.pool = None
|
td.pool = None
|
||||||
td.passage_index = None
|
td.passage_index = None
|
||||||
td.choose_index = None
|
td.choose_index = None
|
||||||
|
@ -1491,6 +1475,21 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
r.current_pool = None
|
r.current_pool = None
|
||||||
await r.asave()
|
await r.asave()
|
||||||
|
|
||||||
|
await self.channel_layer.group_send(
|
||||||
|
f"tournament-{self.tournament.id}",
|
||||||
|
{
|
||||||
|
'tid': self.tournament_id,
|
||||||
|
'type': 'draw.send_poules',
|
||||||
|
'round': r.number,
|
||||||
|
'poules': [
|
||||||
|
{
|
||||||
|
'letter': pool.get_letter_display(),
|
||||||
|
'teams': await pool.atrigrams(),
|
||||||
|
}
|
||||||
|
async for pool in r.pool_set.order_by('letter').all()
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
round_tds = {td.id: td async for td in r.team_draws.prefetch_related('participation__team')}
|
round_tds = {td.id: td async for td in r.team_draws.prefetch_related('participation__team')}
|
||||||
|
|
||||||
# Reset the last dice
|
# Reset the last dice
|
||||||
|
@ -1560,8 +1559,45 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
'team': last_td.participation.team.trigram,
|
'team': last_td.participation.team.trigram,
|
||||||
'result': None})
|
'result': None})
|
||||||
break
|
break
|
||||||
else:
|
elif r.number == 1:
|
||||||
|
# Cancel the draw if it is the first round
|
||||||
await self.abort()
|
await self.abort()
|
||||||
|
else:
|
||||||
|
# Go back to the first round after resetting all
|
||||||
|
previous_round = await self.tournament.draw.round_set \
|
||||||
|
.prefetch_related('current_pool__current_team__participation__team').aget(number=r.number - 1)
|
||||||
|
self.tournament.draw.current_round = previous_round
|
||||||
|
await self.tournament.draw.asave()
|
||||||
|
|
||||||
|
async for td in previous_round.team_draws.prefetch_related('participation__team').all():
|
||||||
|
await self.channel_layer.group_send(
|
||||||
|
f"tournament-{self.tournament.id}", {'tid': self.tournament_id, 'type': 'draw.dice',
|
||||||
|
'team': td.participation.team.trigram,
|
||||||
|
'result': td.choice_dice})
|
||||||
|
|
||||||
|
previous_pool = previous_round.current_pool
|
||||||
|
|
||||||
|
td = previous_pool.current_team
|
||||||
|
td.purposed = td.accepted
|
||||||
|
td.accepted = None
|
||||||
|
await td.asave()
|
||||||
|
|
||||||
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
|
{'tid': self.tournament_id, 'type': 'draw.dice_visibility',
|
||||||
|
'visible': False})
|
||||||
|
|
||||||
|
await self.channel_layer.group_send(f"team-{td.participation.team.trigram}",
|
||||||
|
{'tid': self.tournament_id, 'type': 'draw.buttons_visibility',
|
||||||
|
'visible': True})
|
||||||
|
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
||||||
|
{'tid': self.tournament_id, 'type': 'draw.buttons_visibility',
|
||||||
|
'visible': True})
|
||||||
|
|
||||||
|
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||||
|
{'tid': self.tournament_id, 'type': 'draw.set_problem',
|
||||||
|
'round': previous_round.number,
|
||||||
|
'team': td.participation.team.trigram,
|
||||||
|
'problem': td.accepted})
|
||||||
|
|
||||||
async def draw_alert(self, content):
|
async def draw_alert(self, content):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue