2017-06-21 07:08:28 +02:00
|
|
|
from ..decorators import kfet_is_team
|
|
|
|
from ..utils import DjangoJsonWebsocketConsumer, PermConsumerMixin
|
|
|
|
from .open import kfet_open
|
|
|
|
|
|
|
|
|
|
|
|
class OpenKfetConsumer(PermConsumerMixin, DjangoJsonWebsocketConsumer):
|
|
|
|
"""Consumer for K-Fêt Open.
|
|
|
|
|
|
|
|
WS groups:
|
|
|
|
kfet.open.base: Only carries the values visible for all users.
|
|
|
|
kfet.open.team: Carries all values (raw status...).
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2022-06-27 15:34:24 +02:00
|
|
|
async def open_status(self, event):
|
|
|
|
await self.send_json(event)
|
2017-06-21 07:08:28 +02:00
|
|
|
|
2022-06-27 15:34:24 +02:00
|
|
|
async def connect(self):
|
2017-06-21 07:08:28 +02:00
|
|
|
"""Send current status on connect."""
|
2022-06-27 15:34:24 +02:00
|
|
|
await super().connect()
|
|
|
|
|
|
|
|
group = "team" if kfet_is_team(self.user) else "base"
|
|
|
|
|
|
|
|
await self.channel_layer.group_add(f"kfet.open.{group}", self.channel_name)
|
|
|
|
|
|
|
|
await self.send_json(kfet_open.export(self.user))
|