1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-24 11:08:46 +02:00

Add export button

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-03-25 20:38:58 +01:00
parent e95d511017
commit b838f1b3f0
5 changed files with 134 additions and 2 deletions

View File

@ -1,5 +1,6 @@
# Copyright (C) 2023 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from collections import OrderedDict
from random import randint
@ -85,6 +86,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
await self.accept_problem(**content)
case 'reject':
await self.reject_problem(**content)
case 'export':
await self.export(**content)
@ensure_orga
async def start_draw(self, fmt, **kwargs):
@ -503,6 +506,9 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
{'type': 'draw.dice_visibility', 'visible': True})
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
{'type': 'draw.export_visibility', 'visible': True})
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}",
@ -572,6 +578,15 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
{'type': 'draw.set_active', 'draw': self.tournament.draw})
async def export(self, **kwargs):
async for r in self.tournament.draw.round_set.all():
async for pool in r.pool_set.all():
if await sync_to_async(lambda: pool.exportable)():
await sync_to_async(pool.export)()
await self.channel_layer.group_send(f"volunteer-{self.tournament.id}",
{'type': 'draw.export_visibility', 'visible': False})
async def draw_alert(self, content):
return await self.alert(**content)
@ -593,6 +608,9 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
async def draw_buttons_visibility(self, content):
await self.send_json({'type': 'buttons_visibility', 'visible': content['visible']})
async def draw_export_visibility(self, content):
await self.send_json({'type': 'export_visibility', 'visible': content['visible']})
async def draw_send_poules(self, content):
await self.send_json({'type': 'set_poules', 'round': content['round'].number,
'poules': [{'letter': pool.get_letter_display(), 'teams': await pool.atrigrams()}