feat: stage 헬퍼 (get_stage, set_stage, can_accept_votes)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
23
app.py
23
app.py
@@ -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", {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user