mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-29 20:31:11 +02:00
Auto-generate tables
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -96,6 +96,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
await Pool.objects.acreate(round=r, letter=j + 1, size=f)
|
||||
for participation in self.participations:
|
||||
await TeamDraw.objects.acreate(participation=participation, round=r)
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.send_poules', 'round': r})
|
||||
|
||||
draw.current_round = r1
|
||||
await sync_to_async(draw.save)()
|
||||
@ -106,6 +108,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
{'type': 'draw.start', 'fmt': fmt, 'draw': draw})
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_info', 'draw': draw})
|
||||
await self.channel_layer.group_send(f"tournament-{self.tournament.id}",
|
||||
{'type': 'draw.set_active', 'draw': self.tournament.draw})
|
||||
|
||||
async def draw_start(self, content):
|
||||
await self.alert(_("The draw for the tournament {tournament} will start.")\
|
||||
@ -225,8 +229,14 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
await self.channel_layer.group_send(f"team-{td.participation.team.trigram}",
|
||||
{'type': 'draw.dice_visibility', 'visible': True})
|
||||
|
||||
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}",
|
||||
{'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})
|
||||
elif state == 'DICE_ORDER_POULE' and \
|
||||
not await TeamDraw.objects.filter(pool=self.tournament.draw.current_round.current_pool,
|
||||
last_dice__isnull=True).aexists():
|
||||
@ -238,7 +248,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
tds.append(td)
|
||||
|
||||
dices = {td: td.last_dice for td in tds}
|
||||
values = list(dices)
|
||||
values = list(dices.values())
|
||||
error = False
|
||||
for v in set(values):
|
||||
if values.count(v) > 1:
|
||||
@ -271,6 +281,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
|
||||
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):
|
||||
return await self.alert(**content)
|
||||
@ -286,3 +298,19 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
|
||||
async def draw_dice_visibility(self, content):
|
||||
await self.send_json({'type': 'dice_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()}
|
||||
async for pool in content['round'].pool_set.order_by('letter').all()]})
|
||||
|
||||
async def draw_set_active(self, content):
|
||||
r = content['draw'].current_round
|
||||
await self.send_json(
|
||||
await sync_to_async(lambda: {
|
||||
'type': 'set_active',
|
||||
'round': r.number,
|
||||
'poule': r.current_pool.get_letter_display() if r.current_pool else None,
|
||||
'team': r.current_pool.current_team.participation.team.trigram \
|
||||
if r.current_pool and r.current_pool.current_team else None,
|
||||
})())
|
||||
|
Reference in New Issue
Block a user