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

Add ability to fake the draw for admins

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-05-19 18:24:01 +02:00
parent 29074c4bfd
commit 310ac70a74
2 changed files with 45 additions and 14 deletions

View File

@ -315,6 +315,10 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
# Launch the dice and get the result
res = randint(1, 100)
if self.registration.is_admin and 'result' in kwargs \
and isinstance(kwargs['result'], int) and (1 <= kwargs['result'] <= 100):
# Admins can force the result
res = int(kwargs['result'])
if state == 'DICE_SELECT_POULES':
team_draw.passage_dice = res
else:
@ -591,6 +595,11 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
while True:
# Choose a random problem
problem = randint(1, len(settings.PROBLEMS))
if self.registration.is_admin and 'problem' in kwargs \
and isinstance(kwargs['problem'], int) and (1 <= kwargs['problem'] <= len(settings.PROBLEMS)):
# Admins can force the draw
problem = int(kwargs['problem'])
# Check that the user didn't already accept this problem for the first round
# if this is the second round
if await TeamDraw.objects.filter(participation_id=td.participation_id,