mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-24 15:00:30 +02:00
Add cancel button to cancel the last step (works for the last problem acceptance for now)
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -115,6 +115,9 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
case 'abort':
|
||||
# Abort the current draw
|
||||
await self.abort(**content)
|
||||
case 'cancel':
|
||||
# Cancel the last step
|
||||
await self.cancel_last_step(**content)
|
||||
case 'dice':
|
||||
# Launch a dice
|
||||
await self.process_dice(**content)
|
||||
@ -647,7 +650,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
:param pool: The pool to end.
|
||||
"""
|
||||
msg = self.tournament.draw.last_message
|
||||
r = pool.round
|
||||
r = self.tournament.draw.current_round
|
||||
|
||||
if pool.size == 5:
|
||||
# Maybe reorder teams if the same problem is presented twice
|
||||
@ -925,6 +928,49 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_active', 'draw': self.tournament.draw})
|
||||
|
||||
@ensure_orga
|
||||
async def cancel_last_step(self, **kwargs):
|
||||
"""
|
||||
Cancel the last step of the draw.
|
||||
"""
|
||||
if not await Draw.objects.filter(tournament=self.tournament).aexists():
|
||||
return await self.alert(_("The draw has not started yet."), 'danger')
|
||||
|
||||
state = self.tournament.draw.get_state()
|
||||
|
||||
self.tournament.draw.last_message = ""
|
||||
await self.tournament.draw.asave()
|
||||
|
||||
r = self.tournament.draw.current_round
|
||||
|
||||
if state == 'DRAW_ENDED' or state == 'WAITING_FINAL':
|
||||
td = self.tournament.draw.current_round.current_pool.current_team
|
||||
td.purposed = td.accepted
|
||||
td.accepted = None
|
||||
await td.asave()
|
||||
|
||||
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
||||
{'type': 'draw.continue_visibility', 'visible': False})
|
||||
|
||||
await self.channel_layer.group_send(f"team-{td.participation.team.trigram}",
|
||||
{'type': 'draw.buttons_visibility', 'visible': True})
|
||||
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
|
||||
{'type': 'draw.buttons_visibility', 'visible': True})
|
||||
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_problem',
|
||||
'round': r.number,
|
||||
'team': td.participation.team.trigram,
|
||||
'problem': td.accepted})
|
||||
elif state == 'WAITING_DRAW_PROBLEM':
|
||||
pass
|
||||
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_info', 'draw': self.tournament.draw})
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_active', 'draw': self.tournament.draw})
|
||||
|
||||
|
||||
async def draw_alert(self, content):
|
||||
"""
|
||||
Send alert to the current user.
|
||||
|
Reference in New Issue
Block a user