feat(event): option to disable an event

This commit is contained in:
2026-10-16 00:18:36 +02:00
parent b837abdba0
commit 15ab9a14ac
8 changed files with 89 additions and 9 deletions
+5 -3
View File
@@ -16,7 +16,9 @@ from .wire import encode, to_epoch_ms
class ClockConsumer(AsyncWebsocketConsumer):
async def connect(self):
self.event_path = self.scope["url_route"]["kwargs"]["event_path"]
self.event = await self._get_enabled_event(self.event_path)
self.event = await self._get_enabled_event(
self.event_path, self.scope.get("user")
)
if self.event is None:
await self.close()
return
@@ -62,8 +64,8 @@ class ClockConsumer(AsyncWebsocketConsumer):
)
@database_sync_to_async
def _get_enabled_event(self, event_path):
event = Event.objects.filter(path=event_path).first()
def _get_enabled_event(self, event_path, user):
event = Event.objects.available_to(user).filter(path=event_path).first()
if event is None:
return None
if not Game.objects.enabled_for_event(event).filter(path="clock").exists():