Add timed bidding support with countdown displays and debug view
- Added `bidding_duration` field to `DraftSessionSettings` model and migration. - Updated `DraftStateManager` to manage bidding start/end times using session settings. - Extended WebSocket payloads to include bidding timer data. - Added `DraftCountdownClock` React component and integrated into admin and participant UIs. - Created new `DraftDebug` view, template, and front-end component for real-time state debugging. - Updated utility functions to handle new timer fields in draft state. - Changed script tags in templates to load with `defer` for non-blocking execution.
This commit is contained in:
@@ -40,7 +40,7 @@ class DraftConsumerBase(AsyncJsonWebsocketConsumer):
|
||||
|
||||
self.group_names = DraftGroupChannelNames(draft_hashid)
|
||||
self.cache_keys = DraftCacheKeys(draft_hashid)
|
||||
self.draft_state = DraftStateManager(draft_hashid)
|
||||
self.draft_state = DraftStateManager(draft_hashid, self.draft_session.settings)
|
||||
|
||||
self.user = self.scope["user"]
|
||||
if not self.should_accept_user():
|
||||
@@ -133,7 +133,7 @@ class DraftConsumerBase(AsyncJsonWebsocketConsumer):
|
||||
draft_session_id = DraftSession.decode_id(draft_session_id_hashed)
|
||||
if draft_session_id:
|
||||
draft_session = DraftSession.objects.select_related(
|
||||
"season", "season__league"
|
||||
"season", "season__league", "settings"
|
||||
).get(pk=draft_session_id)
|
||||
else:
|
||||
raise Exception()
|
||||
@@ -198,14 +198,17 @@ class DraftAdminConsumer(DraftConsumerBase):
|
||||
}
|
||||
)
|
||||
if event_type == DraftMessage.BID_START_REQUEST:
|
||||
self.draft_state
|
||||
self.draft_state.start_timer()
|
||||
await self.channel_layer.group_send(
|
||||
self.group_names.session,
|
||||
{
|
||||
"type": "broadcast.session",
|
||||
"subtype": DraftMessage.BID_START_INFORM,
|
||||
"payload": {
|
||||
"current_movie": self.draft_state.get_summary()['current_movie']
|
||||
"current_movie": self.draft_state.get_summary()['current_movie'],
|
||||
"bidding_duration": self.draft_state.settings.bidding_duration,
|
||||
"bidding_timer_end": self.draft_state.get_timer_end(),
|
||||
"bidding_timer_start": self.draft_state.get_timer_start()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user