feat: edit hands from the viewer + "not my hand" disown
Addresses "no way to edit hands" and cleaning up misattributed ones:
- hand viewer (/hand/{id}) gets an "✎ Edit this hand" panel: position, cards,
board, your net, tag, lesson → Save (existing PATCH), plus Delete.
- "Not my hand" → POST /hand/{id}/disown → poker.disown_hand clears the flat hero
fields and rewrites structured with hero_involved=false, so a hand mislabeled as
Brian's becomes a clean observed hand (replay stops showing him as hero).
1 test. Full suite 156 green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -644,6 +644,28 @@ def update_hand(hand_id: int, **fields) -> dict | None:
|
||||
return get_hand(hand_id)
|
||||
|
||||
|
||||
def disown_hand(hand_id: int) -> dict | None:
|
||||
"""Reclassify a hand as OBSERVED (not Brian's) — fixes one that was mislabeled
|
||||
as his. Clears the flat hero fields and rewrites the structured JSON with
|
||||
hero_involved=false so the replay stops showing him as hero."""
|
||||
h = get_hand(hand_id)
|
||||
if not h:
|
||||
return None
|
||||
structured = h.get("structured")
|
||||
if isinstance(structured, str):
|
||||
structured = _safe_json(structured)
|
||||
if isinstance(structured, dict):
|
||||
structured = normalize_structured({**structured, "hero_involved": False})
|
||||
conn = _c()
|
||||
with conn:
|
||||
conn.execute(
|
||||
"UPDATE poker_hands SET position = NULL, hole_cards = NULL, result = NULL, "
|
||||
"structured = ? WHERE id = ?",
|
||||
(json.dumps(structured) if structured else None, hand_id),
|
||||
)
|
||||
return get_hand(hand_id)
|
||||
|
||||
|
||||
def list_hands(session_id: int | None = None) -> list[dict]:
|
||||
sid = _resolve(session_id)
|
||||
if sid is None:
|
||||
|
||||
Reference in New Issue
Block a user