A.7-polish-3 stat-block title + arcana fields across 3 surfaces + spread-switch unlock after DEL — TDD. End-of-session 2026-05-25 PM. Two changes bundled (both user-requested as round-out work for tonight's final push):
1. Stat-block restructure per [[project-image-based-deck-face-rendering]]'s locked Q3 spec. User noticed during browser verify that image-mode card surfaces (Minchiate-equipped on my_sign main stage + My Sign applet + Sea Stage modal in my_sea) show only the EMANATION label in the stat-block — no title, no arcana type, no keywords (Minchiate keywords are empty per A.1 seed). For text-mode decks (Earthman, RWS) the title + arcana render ON the card; for image-mode the card is just an image so all textual metadata MUST move to the stat-block. Spec was originally written for image-mode only but user explicitly asked for it universally so non-image cards also get the info in the stat-block (visible duplicates w. card content — acceptable tradeoff per user). Implementation: added `<p class="stat-face-title">` + `<p class="stat-face-arcana">` to both upright + reversed `.stat-face` blocks in `my_sign.html` (line ~58) + `_sea_stage.html` (the modal). For `_applet-my-sign.html` (no SPIN btn, no reversed face), rendered server-side from `card.name` + `card.get_arcana_display` + the new `data-arcana-key="{{ card.arcana }}"` attr on the stat-block wrapper. New JS helper `StageCard.populateStatExtras(statBlock, card, opts)` in `stage-card.js` parallels the existing `populateKeywords` — fills `.stat-face-title` (card name minus any "Title, Qualifier" Earthman pattern stripping) + `.stat-face-arcana` (`_arcanaDisplay(card)` reused) + sets `data-arcana-key` on the stat-block parent for SCSS color-keying. Exported alongside populateKeywords; called from `my_sign.html` inline + `sea.js`'s `_populate` (the 2 dynamic stat-block sites). `sig-select.js` (room sig select) intentionally NOT updated — that's A.8 territory + its stat block markup differs. SCSS: extended `stat-block-shared` mixin in `_card-deck.scss` w. `.stat-face-title` (font-weight 700, color --quiUser default; `[data-arcana-key="MAJOR"]` selector flips to --terUser matching the contour-stroke arcana-color convention) + `.stat-face-arcana` (uppercase letter-spaced like `.stat-face-label`). Same rules duplicated in `_billboard.scss` `.my-sign-applet-stat-block` block (different sizing via `--applet-card-w` container query). `:empty` rule hides both title + arcana when JS hasn't populated yet (rest state — prevents zero-height paragraphs inflating the stat block). Also added user-spec'd underline to `.stat-face-label` (text-decoration: underline + 0.15em offset).
2. Spread-switch policy unlock after DEL. User-reported AUTO DRAW failure ("only works with default SOA spread, others give visual click feedback but no cards") + spread-switch failure ("won't persist with a partial draw either, only SAO will"). Investigated: root cause is `views.my_sea_lock` line 372 returning `409 spread_mismatch` whenever the POST's spread != the existing `MySeaDraw` row's spread. The row spread is committed at first-card moment and `active_draw_for` returns rows for 24h regardless of hand state (even empty post-DEL rows still hold the spread lock). Combobox switches visually but every subsequent POST 409s. Refined policy: spread is locked only during an ACTIVE non-empty draw. Once the user DELs (clears hand to []), the spread lock lifts — a POST w. a different spread UPDATES the existing row's spread + populates the new hand. The 24h quota window (created_at + paid_through_at) is preserved so the cooldown clock stays put. Sneaky-POST mitigation is still in effect for mid-non-empty-draw spread switches (those still 409). Server-side: 4-line change in `views.my_sea_lock` — `spread_changed = existing.spread != spread`; `if spread_changed and existing.hand: return 409` (preserves prior behavior for non-empty hands); `if spread_changed: existing.spread = spread; update_fields.append("spread")` in the update block. New IT `MySeaLockHandViewTest.test_lock_post_spread_switch_after_del_succeeds` exercises the full flow: first POST creates row w. spread=SAO + 1 card; DEL clears hand; second POST w. spread=waite-smith + different card → 200 + row.spread is now "waite-smith" + row.created_at unchanged. Existing `test_lock_post_spread_mismatch_within_quota_returns_409` test docstring updated to clarify the new policy ("for the duration of an ACTIVE non-empty draw"); the 409 assertion still holds for its specific scenario (mid-non-empty-draw switch).
Tests: 1 new IT green (lock-view spread-switch-after-DEL); 14/14 MySeaLockHandViewTest class green; 1307/1307 IT+UT total green (74s; +1 from 26cdf0d's 1306). Memory: `project_image_based_deck_face_rendering.md` has the detailed AUTO DRAW root-cause writeup; tomorrow's A.8 work is the only remaining image-rendering surface
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1559,8 +1559,8 @@ class MySeaLockHandViewTest(TestCase):
|
||||
self.assertEqual(len(rows.first().hand), 3)
|
||||
|
||||
def test_lock_post_spread_mismatch_within_quota_returns_409(self):
|
||||
# Spread is committed at first-card moment; switching to a
|
||||
# different spread mid-quota-window is rejected.
|
||||
# Spread is committed at first-card moment for the duration of an
|
||||
# ACTIVE non-empty draw. Switching spread mid-non-empty-draw → 409.
|
||||
import json
|
||||
from apps.epic.models import TarotCard
|
||||
cards = list(TarotCard.objects.exclude(id=self.target.id)[:3])
|
||||
@@ -1580,6 +1580,52 @@ class MySeaLockHandViewTest(TestCase):
|
||||
)
|
||||
self.assertEqual(response.status_code, 409)
|
||||
|
||||
def test_lock_post_spread_switch_after_del_succeeds(self):
|
||||
"""Sprint A.7-polish-3 — once the user DELs (clears hand to []), the
|
||||
spread lock lifts: a subsequent POST with a different spread
|
||||
UPDATES the existing row's spread + populates the new hand. The 24h
|
||||
quota window (created_at + paid_through_at) is preserved — only the
|
||||
spread field changes. Fixes the AUTO-DRAW-only-works-on-SAO user bug
|
||||
report (2026-05-25 PM): users couldn't switch spreads even after
|
||||
DELing because the row's spread stayed locked for the full 24h."""
|
||||
import json
|
||||
from apps.epic.models import TarotCard
|
||||
from apps.gameboard.models import MySeaDraw
|
||||
cards = list(TarotCard.objects.exclude(id=self.target.id)[:3])
|
||||
# First draw under SAO — creates row w. spread=SAO + 1 card.
|
||||
self.client.post(
|
||||
self.url, data=json.dumps({
|
||||
"spread": "situation-action-outcome",
|
||||
"hand": [{"position": "lay", "card_id": cards[0].id,
|
||||
"reversed": False, "polarity": "gravity"}],
|
||||
}),
|
||||
content_type="application/json",
|
||||
)
|
||||
row = MySeaDraw.objects.get(user=self.user)
|
||||
self.assertEqual(row.spread, "situation-action-outcome")
|
||||
original_created_at = row.created_at
|
||||
# DEL clears hand to [] but preserves the row.
|
||||
self.client.post(reverse("my_sea_delete"))
|
||||
row.refresh_from_db()
|
||||
self.assertEqual(row.hand, [])
|
||||
self.assertEqual(row.spread, "situation-action-outcome")
|
||||
# Now POST a draw under a DIFFERENT spread. Should succeed +
|
||||
# update the row's spread.
|
||||
response = self.client.post(
|
||||
self.url, data=json.dumps({
|
||||
"spread": "waite-smith",
|
||||
"hand": [{"position": "crown", "card_id": cards[1].id,
|
||||
"reversed": False, "polarity": "levity"}],
|
||||
}),
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
row.refresh_from_db()
|
||||
self.assertEqual(row.spread, "waite-smith")
|
||||
self.assertEqual(len(row.hand), 1)
|
||||
# The 24h quota window is preserved — created_at unchanged.
|
||||
self.assertEqual(row.created_at, original_created_at)
|
||||
|
||||
def test_lock_post_returns_hand_complete_flag(self):
|
||||
# Body includes `hand_complete` so the JS can decide whether to
|
||||
# transition the picker into post-completion state (DEL enable,
|
||||
|
||||
@@ -367,9 +367,17 @@ def my_sea_lock(request):
|
||||
if existing is not None:
|
||||
# Mid-draw upsert OR post-DEL re-draw (which Sprint 6 will route
|
||||
# through the gatekeeper but the endpoint stays permissive here).
|
||||
# Spread-switch attempts get 409 — the spread is committed at
|
||||
# first-card moment.
|
||||
if existing.spread != spread:
|
||||
# Spread-switch policy (refined 2026-05-25 PM per user bug report —
|
||||
# AUTO DRAW failing on non-SAO spreads with 409): the spread is
|
||||
# committed at first-card moment for the duration of the active
|
||||
# NON-EMPTY draw. Once the user DELs (clears hand to []) the row
|
||||
# stays alive for its 24h quota window but the spread lock lifts —
|
||||
# the user can pick a fresh spread for the next draw without losing
|
||||
# the cooldown clock. Mid-non-empty-draw spread switches still get
|
||||
# 409 to prevent the "sneaky POST" of a different spread without an
|
||||
# explicit DEL gesture.
|
||||
spread_changed = existing.spread != spread
|
||||
if spread_changed and existing.hand:
|
||||
return JsonResponse({"error": "spread_mismatch"}, status=409)
|
||||
# If this row carried a paid-through credit (set by `my_sea_paid_
|
||||
# draw` at commit time) AND we're transitioning empty→non-empty,
|
||||
@@ -379,6 +387,9 @@ def my_sea_lock(request):
|
||||
was_empty = not existing.hand
|
||||
existing.hand = hand
|
||||
update_fields = ["hand"]
|
||||
if spread_changed:
|
||||
existing.spread = spread
|
||||
update_fields.append("spread")
|
||||
if (was_empty and hand
|
||||
and existing.paid_through_at is not None):
|
||||
existing.paid_through_at = None
|
||||
|
||||
Reference in New Issue
Block a user