mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-29 20:31:11 +02:00
Add Abort button
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -67,19 +67,18 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
match content['type']:
|
||||
case 'start_draw':
|
||||
await self.start_draw(**content)
|
||||
case 'abort':
|
||||
await self.abort(**content)
|
||||
case 'dice':
|
||||
await self.process_dice(**content)
|
||||
|
||||
@ensure_orga
|
||||
async def start_draw(self, fmt, **kwargs):
|
||||
print(fmt, kwargs)
|
||||
try:
|
||||
fmt = list(map(int, fmt.split('+')))
|
||||
except ValueError as e:
|
||||
return await self.alert(_("Invalid format"), 'danger')
|
||||
|
||||
print(fmt, sum(fmt), len(self.participations))
|
||||
|
||||
if sum(fmt) != len(self.participations):
|
||||
return await self.alert(
|
||||
_("The sum must be equal to the number of teams: expected {len}, got {sum}")\
|
||||
@ -117,6 +116,16 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
await self.send_json({'type': 'draw_start', 'fmt': content['fmt'],
|
||||
'trigrams': [p.team.trigram for p in self.participations]})
|
||||
|
||||
@ensure_orga
|
||||
async def abort(self, **kwargs):
|
||||
await sync_to_async(self.tournament.draw.delete)()
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}", {'type': 'draw_abort'})
|
||||
|
||||
async def draw_abort(self, content):
|
||||
await self.alert(_("The draw for the tournament {tournament} is aborted.")\
|
||||
.format(tournament=self.tournament.name), 'danger')
|
||||
await self.send_json({'type': 'abort'})
|
||||
|
||||
|
||||
async def process_dice(self, trigram: str | None = None, **kwargs):
|
||||
if self.registration.is_volunteer:
|
||||
|
Reference in New Issue
Block a user