feat: stage 헬퍼 (get_stage, set_stage, can_accept_votes)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
th-kim0823
2026-04-27 19:45:52 +09:00
parent c675b8c297
commit 70f326eb20
2 changed files with 57 additions and 0 deletions

23
app.py
View File

@@ -111,6 +111,29 @@ def set_voting_open(flag):
update_data(_fn)
VALID_STAGES = ("intro", "topics", "vote")
def get_stage():
return load_data().get("settings", {}).get("current_stage", "intro")
def set_stage(stage):
if stage not in VALID_STAGES:
raise ValueError(f"invalid stage: {stage!r}")
def _fn(data):
data["settings"]["current_stage"] = stage
if stage == "vote":
data["settings"]["voting_open"] = True
update_data(_fn)
def can_accept_votes(data):
s = data.get("settings", {})
return s.get("current_stage") == "vote" and s.get("voting_open", False)
def get_tie_breaks():
return load_data().get("tie_breaks", {})