Add DRF API app and real-time draft management UI
- Created new `api` Django app with serializers, viewsets, and routers to expose draft sessions, participants, and movie data. - Registered `api` app in settings and updated root URL configuration. - Extended WebSocket consumers with `inform.draft_status` / `request.draft_status` to allow fetching current draft state. - Updated `DraftSession` and related models to support reverse lookups for draft picks. - Enhanced draft state manager to include `draft_order` in summaries. - Added React WebSocket context provider, connection status component, and new admin/participant panels with phase and participant tracking. - Updated SCSS for participant lists, phase indicators, and status badges. - Modified Django templates to mount new React roots for admin and participant views. - Updated Webpack dev server config to proxy WebSocket connections.
This commit is contained in:
@@ -65,7 +65,6 @@ class DraftStateManager:
|
||||
self.cache = cache
|
||||
self.keys = DraftCacheKeys(session_id)
|
||||
self._phase = self.cache.get(self.keys.phase, DraftPhase.WAITING)
|
||||
self.draft_order = self.cache.get(self.keys.draft_order)
|
||||
|
||||
|
||||
# === Phase Management ===
|
||||
@@ -98,7 +97,9 @@ class DraftStateManager:
|
||||
return json.loads(self.cache.get(self.keys.draft_order,"[]"))
|
||||
|
||||
@draft_order.setter
|
||||
def draft_order(self, draft_order: list[User]):
|
||||
def draft_order(self, draft_order: list[str]):
|
||||
if not isinstance(draft_order, list):
|
||||
return
|
||||
self.cache.set(self.keys.draft_order,json.dumps(draft_order))
|
||||
|
||||
# === Current Nomination / Bid ===
|
||||
@@ -130,8 +131,9 @@ class DraftStateManager:
|
||||
def get_summary(self) -> dict:
|
||||
return {
|
||||
"phase": self.phase,
|
||||
"draft_order": self.draft_order,
|
||||
"connected_users": self.connected_users,
|
||||
"current_movie": self.cache.get(self.keys.current_movie),
|
||||
"bids": self.get_bids(),
|
||||
"timer_end": self.get_timer_end(),
|
||||
# "current_movie": self.cache.get(self.keys.current_movie),
|
||||
# "bids": self.get_bids(),
|
||||
# "timer_end": self.get_timer_end(),
|
||||
}
|
||||
Reference in New Issue
Block a user