1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-05-17 02:52:48 +00:00

Allow to impersonate user on draw interface

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-27 09:55:33 +02:00
parent 1abe463575
commit 4026fe53c3
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -9,6 +9,7 @@ from random import randint, shuffle
from asgiref.sync import sync_to_async from asgiref.sync import sync_to_async
from channels.generic.websocket import AsyncJsonWebsocketConsumer from channels.generic.websocket import AsyncJsonWebsocketConsumer
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.utils import translation from django.utils import translation
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -44,6 +45,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
We accept only if this is a user of a team of the associated tournament, or a volunteer We accept only if this is a user of a team of the associated tournament, or a volunteer
of the tournament. of the tournament.
""" """
if '_fake_user_id' in self.scope['session']:
self.scope['user'] = await User.objects.aget(pk=self.scope['session']['_fake_user_id'])
# Fetch the registration of the current user # Fetch the registration of the current user
user = self.scope['user'] user = self.scope['user']