major-domo-v2/models/draft_data.py
Cal Corum ff62529ee3 Add draft pause/resume functionality
- Add paused field to DraftData model
- Add pause_draft() and resume_draft() methods to DraftService
- Add /draft-admin pause and /draft-admin resume commands
- Block picks in /draft command when draft is paused
- Skip auto-draft in draft_monitor when draft is paused
- Update status embeds to show paused state
- Add comprehensive tests for pause/resume

When paused:
- Timer is stopped (set to False)
- Deadline is set far in future
- All /draft picks are blocked
- Auto-draft monitor skips processing

When resumed:
- Timer is restarted with fresh deadline
- Picks are allowed again

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 19:58:37 -06:00

58 lines
2.0 KiB
Python

"""
Draft configuration and state model
Represents the current draft settings and timer state.
"""
from typing import Optional
from datetime import datetime
from pydantic import Field, field_validator
from models.base import SBABaseModel
class DraftData(SBABaseModel):
"""Draft configuration and state model."""
currentpick: int = Field(0, description="Current pick number in progress")
timer: bool = Field(False, description="Whether draft timer is active")
paused: bool = Field(False, description="Whether draft is paused (blocks all picks)")
pick_deadline: Optional[datetime] = Field(None, description="Deadline for current pick")
result_channel: Optional[int] = Field(None, description="Discord channel ID for draft results")
ping_channel: Optional[int] = Field(None, description="Discord channel ID for draft pings")
pick_minutes: int = Field(1, description="Minutes allowed per pick")
@field_validator("result_channel", "ping_channel", mode="before")
@classmethod
def cast_channel_ids_to_int(cls, v):
"""Ensure channel IDs are integers (database stores as string)."""
if v is None:
return None
if isinstance(v, str):
return int(v)
return v
@property
def is_draft_active(self) -> bool:
"""Check if the draft is currently active (timer running and not paused)."""
return self.timer and not self.paused
@property
def is_pick_expired(self) -> bool:
"""Check if the current pick deadline has passed."""
if not self.pick_deadline:
return False
return datetime.now() > self.pick_deadline
@property
def can_make_picks(self) -> bool:
"""Check if picks are allowed (not paused)."""
return not self.paused
def __str__(self):
if self.paused:
status = "PAUSED"
elif self.timer:
status = "Active"
else:
status = "Inactive"
return f"Draft {status}: Pick {self.currentpick} ({self.pick_minutes}min timer)"