Compare commits

...

212 Commits

Author SHA1 Message Date
Disco DeDisco
3800c5bdad fixed attribution of .fa-hand-pointer cursor color scheme to ordering according to token-drop sequence instead of seat sequence; updates to accomodate this throughout apps.epic.models & .views, plus new apps.epic migration; assigned #id_sig_cursor_portal a z-index value corresponding to a high position but still beneath the #id_tray apparatus; minor semantic reordering of INSTALLED_APPS in core.settings
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-08 22:53:44 -04:00
Disco DeDisco
12d575a84b fixed seeding problem w. setUp helper causing same FTs to persistently fail
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-08 13:34:22 -04:00
Disco DeDisco
c14b6d7062 fixed some old data in two pipeline errors pointing to new Middle Arcana labels still as Minor Arcana
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-08 12:51:46 -04:00
Disco DeDisco
a7c5468cbc fixed failing channels FT related to Sig select; FT fix only, code written as intended
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-08 12:18:20 -04:00
Disco DeDisco
4da8750c60 fixed tooltip illegibility due to similar color to bg on .sig-overlay when data-polarity='gravity'
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-08 11:57:44 -04:00
Disco DeDisco
cf40f626e6 Sig select: _card-deck.scss extract, WS cursor fixes, own-role indicators, role icon refresh
- New _card-deck.scss: sig select styles moved out of _room.scss + _game-kit.scss
- sig-select.js: 3 WS bug fixes — thumbs-up deferred to window.load (layout settled
  before getBoundingClientRect), hover cursor cleared for all cards on reservation
  (not just the reserved card), applyHover guards against already-reserved roles
- Own-role indicators: gamer now sees their own role-coloured card outline + thumbs-up
- Reservation glow: replaced blurry role+ninUser double-shadow with crisp 2px outline
- Gravity qualifier: Graven text set to --terUser (matches Leavened/--quiUser pattern)
- Role card SVGs refreshed; starter-role-Blank removed
- FTs + Jasmine specs extended for sig select WS behaviour
- setup_sig_session management command for multi-browser manual testing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 11:52:49 -04:00
Disco DeDisco
99a826f6c9 FT: pin AppletMenuDismissTest to portrait viewport (800×1200)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Landscape layout activates sidebar CSS which causes #id_dash_content to
overlap the base-template h2 in CI headless Firefox, triggering
ElementClickInterceptedException. Portrait viewport sidesteps all
landscape breakpoints so the h2 sits safely above #id_dash_content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 01:26:35 -04:00
Disco DeDisco
51fe2614fa overruling other scss specificity in .btn-disabled 2026-04-07 00:43:26 -04:00
Disco DeDisco
56dc094b45 Jasmine: fix 2 failing specs, drop 5 always-pending touch specs
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- FYI btn is now btn-disabled when caution open; rename test to assert
  disabled click does NOT close caution (old toggle expectation was stale)
- Hover-resets-is-reversed: cloneNode post-init has no mouseenter listener
  (direct binding, not delegation); use mouseleave + re-enter on same card
- Remove 3 touch describe blocks (5 specs total); TouchEvent unavailable
  in desktop Firefox means they never ran; touch behaviour covered by FTs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 00:36:28 -04:00
Disco DeDisco
520fdf7862 Sig select: caution tooltip, FLIP/FYI stat block, keyword display
- TarotCard.cautions JSONField + cautions_json property; migrations
  0027–0029 seed The Schizo (number=1) with 4 rival-interaction cautions
  (Roman-numeral card refs: I. The Pervert / II. The Occultist, etc.)
- Sig-select overlay: FLIP (stat-block toggle) + FYI (caution tooltip)
  buttons; nav PRV/NXT portaled outside tooltip at bottom corners (z-70);
  caution tooltip covers stat block (inset:0, z-60, Gaussian blur);
  tooltip click dismisses; FLIP/FYI fully dead while btn-disabled;
  nav wraps circularly (4/4 → 1/4, 1/4 → 4/4)
- SCSS: btn-disabled specificity fix (!important); btn-nav-left/right
  classes; sig-caution-* layout; stat-face keyword lists
- Jasmine suite expanded: stat block + FLIP (5 specs), caution tooltip
  (16 specs) including wrap-around and disabled-button behaviour
- IT tests: TarotCardCautionsTest (5), SigSelectRenderingTest (8)
- Role-card SVG icons added to static/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 00:22:04 -04:00
Disco DeDisco
e2cc38686f XL landscape: revert tray to landscape style; fix sig-stage stretch
- Remove _tray.scss XL (≥1800px) portrait override block entirely
- _isLandscape() no longer returns false at ≥1800px — tray uses
  landscape slide-from-top at all wide landscape widths
- sig-stage: align-self: stretch (was center) so JS sizeSigCard()
  measures correct stage width; card size no longer collapses
- Position strip: horizontal row at top (was vertical column-reverse)
- sig-overlay/sig-stage/sig-deck-grid layout polish at 1100px/1800px

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 20:11:24 -04:00
Disco DeDisco
0bcc7567bb XL landscape polish: btn-primary sizing, tray from right, footer bg, layout fixes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- .btn-xl removed; .btn-primary absorbs 4rem sizing (same as PICK SIGS/PICK ROLES)
- Landscape navbar .btn-primary: 3rem → 4rem to match base; XL stays 4rem (consistent)
- _button-pad.scss XL: base .btn ×1.2 (2.4rem); .btn-xl block deleted
- _tray.scss XL (≥1800px): portrait-style tray (slides from right, z-95)
- tray.js: _isLandscape() returns false at ≥1800px; portrait code paths run throughout
- Footer sidebar: background-color added so opaque footer masks tray sliding behind it
- Copyright .footer-container: bottom → top in landscape sidebar
- #id_room_menu: right: 2.5rem override in _room.scss XL block (cascade fix)
- navbar-text XL: 0.65rem × 1.2 = 0.78rem
- All landscape media queries: max-width: 1440px cutoff removed (already done prior)
- btn-xl class stripped from all 5 templates; test_navbar.py assertion updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 03:02:37 -04:00
Disco DeDisco
6654785f25 XL landscape breakpoint (≥1800px): double sidebar widths + scale content
- _base.scss: new @media (orientation:landscape) and (min-width:1800px) block —
  sidebars 4rem→8rem; navbar btn 3rem→5rem; brand h1 1.2rem→2.4rem; navbar-text
  0.65rem→1.3rem; footer icons 1.75rem→3rem; nav gap 3rem→4rem; footer-container
  0.55rem→0.85rem; container margins 4rem→8rem; h2 portrait-style (2rem, centred)
- _applets.scss: gear btn right 0.5rem→2.5rem; menus right 0.5rem→2rem at ≥1800px
- _game-kit.scss: kit btn right 0.5rem→2.5rem at ≥1800px
- _room.scss: sig-overlay padding-left 4rem→8rem at ≥1800px
- _tray.scss: tray wrap left/right 4rem→8rem at ≥1800px
- room.js: sizeSigModal right inset 64px→128px at ≥1800px viewport width

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 01:41:18 -04:00
Disco DeDisco
99a69202b9 landscape layout: remove max-width cutoff; sig-select stage/grid polish
- All landscape @media queries: drop and (max-width: 1440px) — sidebar layout
  now activates for all landscape orientations regardless of viewport width
- _base.scss landscape container: add max-width:none to override the
  @media(min-width:1200px) rule and fill the full space between sidebars
- sig-select sig-deck-grid: landscape now 9×2 @ 3rem cards; 18×1 at ≥1100px
  (bumped from 992px to avoid last-card clip); card text scales with --sig-card-w
- sig-stat-block: flex:1→flex:0 0 auto with width:--sig-card-w so it matches
  preview card dimensions instead of stretching across the full stage
- room.js sizeSigModal: landscape card width clamped to [90px, 160px]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 01:30:31 -04:00
Disco DeDisco
55bb450d27 z-index audit + aperture fill + resize:end debounce + landscape sig-grid cap
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- #id_aperture_fill: position:fixed→absolute (clips to .room-page, avoids h2/navbar);
  z-index 105→90 (below blur backdrops at z-100); landscape override removed (inset:0 works both orientations)
- _base.scss: landscape footer z-index:100 (matches navbar); corrects unset z-index
- _room.scss: fix stale "navbar z-300" comment; landscape sig-deck-grid columns
  repeat(9,1fr)→repeat(9,minmax(0,90px)) to cap card size on wide viewports
- room.js: add resize:end listeners for scaleTable + sizeSigModal; new IIFE dispatches
  resize:end 500ms after resize stops so both functions re-measure settled layout
- tray.js: extract _reposition() from inline resize handler; wire to both resize and
  resize:end so tray repositions correctly after rapid resize or orientation change

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 00:48:25 -04:00
Disco DeDisco
e28d55ad58 remove obsolete sig-select FTs (S1/S3/S4) based on old sequential 36-card design
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The new sig-select has two parallel 18-card overlays per polarity group (levity:
PC/NC/SC; gravity: BC/EC/AC) — no shared 36-card deck, no active-seat turn order.
S1 (36 cards), S3 (PC picks → deck shrinks → active advances to NC), and S4
(non-active seat blocked) all tested the old design and have been failing in CI.
S2 (seat display order) passed and is kept. Header comment updated to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 23:44:54 -04:00
Disco DeDisco
b110bb6d01 remove obsolete skipped tests; fix billboard applet menu containment; align landscape menus
Deleted skips:
- test_fan_next_button_advances_card (T11) + test_fan_remembers_position_on_reopen (T13):
  fan-nav nav button obstruction — deferred indefinitely, not worth tracking
- test_selected_sig_card_removed_from_deck_for_other_gamers (S5): card count
  mismatch in channels context — grand overhaul pending, obsolete with new sig-select
- Removed stale TODO comment about #id_inv_sig_card (element no longer exists)
- Dropped unused `import unittest` from test_room_sig_select.py

billboard applet menu fix: moved #id_billboard_applet_menu out of
#id_billboard_applets_container — container-type:inline-size was making the
container a containing block for fixed-position descendants, clipping the menu.

Landscape menu alignment: all applet menus now right:0.5rem (flush with gear/kit
buttons in the 4rem right sidebar); added #id_room_menu to the landscape rule.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 23:33:13 -04:00
Disco DeDisco
2892b51101 fix SigSelect Jasmine: return test API from IIFE; pend touch specs on desktop
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
window.SigSelect was being clobbered by the IIFE's undefined return value
(var SigSelect = (function(){...window.SigSelect={...}}()) overwrites window.SigSelect
with undefined). Fixed by using return {} like RoleSelect does.

TouchEvent is not defined in desktop Firefox, so the 5 touch-related specs now
call pending() when the API is absent rather than throwing a ReferenceError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 23:14:56 -04:00
Disco DeDisco
871e94b298 sig-select landscape: stage card now visible; gear/kit btns in right sidebar column
sizeSigModal() no longer uses tray bottomInset in landscape (was over-shrinking the
modal, pushing the stage off-screen); fixed 60px kit-bag-handle clearance instead.
Gear btn + kit btn shifted into the 4rem right sidebar strip (right: 0.5rem) and
nudged down a quarter-rem so they clear the last card in the 9×2 grid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 23:02:32 -04:00
Disco DeDisco
c3ab78cc57 many deck changes, including pentacles to crowns, middle arcana, and major arcana fa icons 2026-04-05 22:32:40 -04:00
Disco DeDisco
c7370bda03 sig-select sprint: SigReservation model + sig_reserve view (OK/NVM hold); full sig-select.js rewrite with stage preview, WS hover cursors, reservation lock (must NVM before OK-ing another card — enforced server-side 409 + JS guard); sizeSigModal() + sizeSigCard() in room.js (JS-based card sizing avoids libsass cqw/cqh limitation); stat block hidden until OK pressed; mobile touch: dismiss stage on outside-grid tap when unfocused; 17 IT + Jasmine specs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 22:01:23 -04:00
Disco DeDisco
a15d91dfe6 wrapped the _gatekeeper.html partial modal to split each function into four different panels; removed deviant landscape styling to unify it with default styling (much more robust now)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-05 19:10:02 -04:00
Disco DeDisco
fecb1fddca restored position circles to their top attr value to avoid old clipping-under-h2 issue; pushed down gatekeeper modal in room.html 2026-04-05 18:32:45 -04:00
Disco DeDisco
2028f1a544 more refinements to Earthman deck names and allegories; tweaks to navbar alignment in landscape media queries
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-05 17:23:51 -04:00
Disco DeDisco
40c747a837 landscape navbar centering: reset portrait margin-right on .container-fluid + margin-left on .navbar-brand so sidebar contents align to horizontal centre; showGuard gains invertY option for modal-grid callers (role-select cards fly away from centre); gameboard.js showPortals gains viewport-half detection so game-kit tooltips show below when tokens are in upper half (landscape clip fix); position-strip top: 0; tighten gear-btn btn-abandon selector to #id_room_menu scope
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 16:54:03 -04:00
Disco DeDisco
40a55721ab major navbar overhaul: .btn-primary.btn-xl now reads CONT GAME and links to the user's most recently active game; log out functionality transferred to new BYE .btn-abandon abutting login spans; tooltips for each asserted via new FTs.test_navbar methods to appear w.in visible area 2026-04-05 16:00:52 -04:00
Disco DeDisco
d4518a0671 fixed jasmine & RoleSelectTest FT methods that were failing due to the Role card reordering in previous pipeline push
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-05 01:52:30 -04:00
Disco DeDisco
74f63a7721 rearranged Role select cards for final presentation ordering; unified Role select tooltip appearance; bottom row of Role select tooltips now appears below bottom row, not layered atop top row; clicking out of one Role select card tooltip and onto another Role select card specifically opens the next tooltip (former behavior made user click once to exit old tooltip, once more to open new one)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-05 01:23:20 -04:00
Disco DeDisco
bd3d7fc7bd role-select.js ensures Role select card stack disappears via WS upon conclusion of Role selection, w. if-conditional support from apps.epic.views; ensured border present on card-stack when .active in _room.scss; changed default #id_tray to unhidden, only hidden during Role select until Role selected; polished & unified Role .card-front, .card.back & .card-stack styling 2026-04-05 01:14:31 -04:00
Disco DeDisco
c00288e256 another #id_pick_sigs_btn IT fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-04 15:10:48 -04:00
Disco DeDisco
b5de96660a fix to pipeline involving new #id_pick_sigs_btn css selector
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-04 15:05:55 -04:00
Disco DeDisco
96bb05a4ba fixed some failing jasmine tests stemming from previous commit
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-04 14:54:54 -04:00
Disco DeDisco
4e07fcf38b fixed several animation & transition problems plaguing the inventory tray 2026-04-04 14:51:49 -04:00
Disco DeDisco
b74f8e1bb1 pick_sigs view + cursor polarity groups; game kit gear menu; housekeeping
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
roles_revealed WS event removed; select_role last pick now fires _notify_all_roles_filled() + stays in ROLE_SELECT; new pick_sigs view (POST /room/<uuid>/pick-sigs) transitions ROLE_SELECT→SIG_SELECT + broadcasts sig_select_started; room.html shows .pick-sigs-btn when all 6 roles filled; PICK SIGS btn absent during mid-selection; 11 new/modified ITs in SelectRoleViewTest + RoomViewAllRolesFilledTest + PickSigsViewTest

consumer: LEVITY_ROLES {PC/NC/SC} + GRAVITY_ROLES {BC/EC/AC}; connects to per-polarity cursor group (cursors_{id}_levity/gravity); receive_json routes cursor_move to cursor group; new handlers all_roles_filled, sig_select_started, cursor_move; CursorMoveConsumerTest (TransactionTestCase, @tag channels): levity cursor reaches fellow levity player, does not reach gravity player

game kit gear menu: #id_game_kit_menu registered in _applets.scss %applet-menu + fixed-position + landscape offset; id_gk_sections_container added to appletContainerIds in applets.js so OK submit dismisses menu; _game_kit_sections.html sections use entry.applet.grid_cols/grid_rows (was hardcoded 6); %applets-grid applied to #id_gk_sections_container (direct parent of sections, not outer wrapper); FT setUp seeds gk-* applets via get_or_create

drama test reorg: integrated/test_views.py deleted (no drama views); two test classes moved to epic/tests/integrated/test_views.py + GameEvent import added; drama/tests/unit/test_models.py → drama/tests/integrated/test_models.py; unit/ dir removed

login form: position:fixed + vertically centred in base styles across all breakpoints; 24rem width, text-align:center; landscape block reduced to left/right sidebar offsets; alert moved below h2; left-side position indicator slots 3/4/5 column order flipped via CSS data-slot selectors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 14:33:35 -04:00
Disco DeDisco
188365f412 game kit gear menu + login form UX polish; left-side position indicator flip
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
game kit: new Applet model rows (context=game-kit) for Trinkets, Tokens, Card Decks, Dice Sets via applets migration 0008; _game_kit_context() helper in gameboard.views; toggle_game_kit_sections view + URL; new _game_kit_sections.html (HTMX-swappable, visibility-conditional) + _game_kit_applet_menu.html partials; game_kit.html wired to gear btn + menu; Dice Sets now renders _forthcoming.html partial; 16 new green ITs in GameKitViewTest + ToggleGameKitSectionsViewTest

login form: .input-group now position:fixed + vertically centred (top:50%) across all breakpoints as default; landscape block reduced to left/right sidebar offsets only; form-control width 24rem, text-align:center; alert block moved below h2 in base.html; alert margin 0.75rem all sides; home.html header switches between Howdy Stranger (anon) and Dashboard (authed)

room.html position indicators: slots 3/4/5 (AC/SC/EC) column order flipped via SCSS data-slot selectors so .fa-chair sits table-side and label+status icon sit outward

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 13:49:48 -04:00
Disco DeDisco
824f35590b minor styling fixes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-03 14:55:37 -04:00
Disco DeDisco
43cb84e8f4 updated assertions in FTs.test_billboard to match the refined prose rendering from last commit
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-02 22:31:29 -04:00
Disco DeDisco
afe8e2b32c tweaked some prose templating in apps.drama.models; updated _applet-billboard-most-recent.html partial to mirror new row-by-row styling & html structure of room_scroll.html
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-02 15:38:44 -04:00
Disco DeDisco
ca38875660 fixed reverse chronological ordering in a pair of FTs clogging the pipeline; added ActivityPub to project; new apps.ap for WebFinger, Actor, Outbox views; apps.lyric.models now contains ap_public_key, ap_private_key fields + ensure_keypair(); new apps.lyric migration accordingly; new in drama.models are to_activity() w. JoinGate, SelectRole, Create compat. & None verb support; new core.urls for /.well-known/webfinger + /ap/ included; cryptography installed, added to reqs.txt; 24 new green UTs & ITs; in sum, project is now read-only ActivityPub node
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-02 15:22:04 -04:00
Disco DeDisco
8538f76b13 new core.middleware sets cookie for scroll timestamp view to local browser time, w. new corresponding tests in core.tests.UTs.test_middleware; apps.lyric.templatetags.lyric_extras determines timestamp format based on duration elapsed since timestamp; apps.bill.tests.ITs.test_views renamed, now also asserts scroll renders event body and time in columns
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-02 14:51:08 -04:00
Disco DeDisco
2a7d4c7410 new migrations in apps.epic for further refinements made to Pope card nomenclature
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-02 14:15:00 -04:00
Disco DeDisco
ed10e58383 small tweaks to h2 text-shadow attr rootvars values
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-02 00:00:14 -04:00
Disco DeDisco
b65cba5ed2 wrapped room table in .room-table-scene div, built styles and scripts to ensure table scales w. available viewport or aperture space
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-01 23:24:17 -04:00
Disco DeDisco
afe79f1a48 other minor styling fixes for gatekeeper modal, position circles 2026-04-01 23:12:49 -04:00
Disco DeDisco
0e5e39b0dc ensured .fa-ban next to empty seat changes to .fa-circle-check at the same time that .fa-chair glows & the pos circle fades out (i.e., when the gamer 'sits') not during or after the role card deposits itself in the tray; minor styling fixes for title h2, incl. text-shadow attr values when selected palette ends in *-light & opacity increases
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-01 22:11:43 -04:00
Disco DeDisco
4860b6ee2a real fix this time, rule overridden last time
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-01 15:41:19 -04:00
Disco DeDisco
c025a38709 small pipeline z-index hierarchy fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-01 15:30:20 -04:00
Disco DeDisco
581ea7e349 stopped card deck nav arrows from inheriting global .btn box-shadow attrs
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-01 15:14:19 -04:00
Disco DeDisco
596175cd1c refined _room.scss styles, incl. .launch-game-btn & .gate-slot
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-04-01 15:10:20 -04:00
Disco DeDisco
1aaf353066 renamed the Popes/0-card trumps from Earthman deck (feat. new apps.epic migrations to reseed); fixes to card deck horizontal scroll speed, game_kit.html, to make scrolling feel more natural 2026-04-01 14:45:53 -04:00
Disco DeDisco
441def9a34 skipped lowlevel grid cell assertion FT clogging pipeline
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-31 00:08:35 -04:00
Disco DeDisco
736b59b5c0 role-select UX: tray timing delays, seat/circle state polish, 394 ITs green
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- _animationPending set before fetch (not in .then()) — blocks WS turn advance during in-flight request
- _placeCardDelay (3s) + _postTrayDelay (3s) give gamer time to see each step; both zeroed by _testReset()
- .role-confirmed class: full-opacity chair after placeCard completes; server-rendered on reload
- Slot circles disappear in join order (slot 1 first) via count-based logic, not role-label matching
- data-active-slot on card-stack; handleTurnChanged writes it for selectRole() to read
- #id_tray_wrap not rendered during gate phase ({% if room.table_status %})
- Tray slide/arc-in slowed to 1s for diagnostics; wobble kept at 0.45s
- Obsolete test_roles_revealed_simultaneously FT removed; T8 tray FT uses ROLE_SELECT room
- Jasmine macrotask flush pattern: await new Promise(r => setTimeout(r, 0)) after fetch .then()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 00:01:04 -04:00
Disco DeDisco
a8592aeaec hex position indicators: chair icons at hex edge midpoints replace gate-slot circles
- Split .gate-overlay into .gate-backdrop (z-100, blur) + .gate-overlay modal (z-120) so .table-position elements (z-110) render above backdrop but below modal
- New _table_positions.html partial: 6 .table-position divs with .fa-chair, role label, and .fa-ban/.fa-circle-check status icons; included unconditionally in room.html
- New epic:room view at /gameboard/room/<uuid>/; gatekeeper redirects there when table_status set; pick_roles redirects there
- role-select.js: adds .active glow to position on selectRole(); swaps .fa-ban→.fa-circle-check in placeCard onComplete; handleTurnChanged clears stale .active from all positions
- FTs: PositionIndicatorsTest (5 tests) + RoleSelectTest 8a/8b (glow + check state)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 18:31:05 -04:00
Disco DeDisco
8b006be138 demo'd old inventory area in room.html to make way for new content (hex table now centered in view); old test suite now targets Role card in #id_tray cells where appropriate, or skips Sig card select until aforementioned new feature deployed; new scripts & jasmine tests too; removed one irrelevant test case from apps.epic.tests.ITs.test_views.SelectRoleViewTest 2026-03-30 16:42:23 -04:00
Disco DeDisco
299a806862 fixed open #id_tray obscuring role select FTs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-29 23:46:23 -04:00
Disco DeDisco
fb782cf5ef maybe don't delete collectstatic static/tests/ dir 2026-03-29 23:39:03 -04:00
Disco DeDisco
224f5e2ad0 fixed Inferno palette --priUser rootvar hue
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 22:57:29 -04:00
Disco DeDisco
96379934d7 trying to reset to get this pipe clear
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-29 22:33:42 -04:00
Disco DeDisco
29a5658b01 'channels' tag now also moved to sequential FT group in pipeline; role-select.js ensures Tray.close() before turn advances so as not to obstruct next gamer selection; RoleSelectSpec.js asserrts this functionality
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 22:08:59 -04:00
Disco DeDisco
73135df7a6 skipped thorny failing FTs; separated out 'two-browser' tag to run before FTs–proper in pipeline for faster fail states
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 21:39:20 -04:00
Disco DeDisco
57f47cc77e another attempt to unclog pipeline; this time a slight sleep timeout used to accomodate headless browser resize flush
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 21:11:24 -04:00
Disco DeDisco
5d21e79be5 more headless patches to address pipeline clog; 'two-browsers' may not have been doing anything before
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 20:41:26 -04:00
Disco DeDisco
ff0883002b added one more FT to the 'two-browser' tag'; for real this might actually unclog the pipeline this time
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 20:04:57 -04:00
Disco DeDisco
7f927741d4 oops, forgot the normal .grid-cell styles, had only updated the landscape media query & not the base condition
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 19:46:59 -04:00
Disco DeDisco
3bf48546e3 tagged some further tests as 'two-browser' in persisting attempt to unclog pipeline fails; _tray.scss .grid-cell border-color changed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 19:43:48 -04:00
Disco DeDisco
6817323f8e further tweaked sepia palette; shored up TestTray for headless browser pipeline testing
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 19:10:42 -04:00
Disco DeDisco
11283118d6 small rootvars hue changes to sepia palette (should rename to 'cedar'); new FTs skipped via unittest to try to unclog pipeline fails
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 18:35:20 -04:00
Disco DeDisco
6c91ec0385 expanded margin of position spots on gatekeeper; cleaned up #id_tray scripts & styles
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-29 15:22:00 -04:00
Disco DeDisco
39db59c71a styles related to #id_tray & apparatus separated out into _tray.scss; new tray.js computes the cell size of the tray grid for item organization; room.html now sports the grid as a separate div so as not to interfere w. tray styling or size; new tests in FTs.test_room_tray 2026-03-29 13:36:44 -04:00
Disco DeDisco
5f643350c5 unskipped certain passing FTs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-29 01:21:33 -04:00
Disco DeDisco
ab41797e57 refined styling for #id_tray & .table-hex, which now mirror ea. other visually as parts of a befelted table
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-29 00:48:19 -04:00
Disco DeDisco
e35855f472 fixed wobble timing condition to be slow enough for headless firefox to catch it
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-28 23:50:08 -04:00
Disco DeDisco
0e5805efd2 'two-browser' tag separates out tests that run multiple browsers in pipeline so that --parallel tests don't interfere w. loading of one or more of such windows; both FTs.test_sharing & woodpecker.yaml updated accordingly
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-28 23:14:31 -04:00
Disco DeDisco
de99b538d2 FTs.test_room_tray.TrayTest now contains setUp() helper to set default window size for methods which don't otherwise define a specific media query; several new Jasmine methods test drawer snap-to-close & wobble functionality
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-28 22:50:43 -04:00
Disco DeDisco
c08b5b764e new landscape styling & scripting for gameroom #id_tray apparatus, & some overall scripting & styling like wobble on click-to-close; new --undUser & --duoUser rootvars universally the table felt values; many new Jasmine tests to handle tray functionality 2026-03-28 21:23:50 -04:00
Disco DeDisco
d63a4bec4a new .active styling to #id_tray_btn, _handle & _grip whenever drawer is open 2026-03-28 19:06:09 -04:00
Disco DeDisco
b35c9b483e seat tray: tray.js, SCSS, FTs, Jasmine specs
- new apps.epic.static tray.js: IIFE with drag-open/click-close/wobble
  behaviour; document-level pointermove+mouseup listeners; reset() for
  Jasmine afterEach; try/catch around setPointerCapture for synthetic events
- _room.scss: #id_tray_wrap fixed-right flex container; #id_tray_handle +
  #id_tray_grip (box-shadow frame, transparent inner window, border-radius
  clip); #id_tray_btn grab cursor; #id_tray bevel box-shadows, margin-left
  gap, height removed (align-items:stretch handles it); tray-wobble keyframes
- _applets.scss + _game-kit.scss: z-index raised (312-318) for primacy over
  tray (310)
- room.html: #id_tray_wrap + children markup; tray.js script tag
- FTs test_room_tray: 5 tests (T1-T5); _simulate_drag via execute_script
  pointer events (replaces unreliable ActionChains drag); wobble asserts on
  #id_tray_wrap not btn
- static_src/tests/TraySpec.js + SpecRunner.html: Jasmine unit tests for
  all tray.js branches

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 18:52:46 -04:00
Disco DeDisco
30ea0fad9d fixed sig-select deck styling, room.html aperture styling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-25 15:50:57 -04:00
Disco DeDisco
62d5c738f9 fixed .sig-card reference in failing IT
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-25 11:08:19 -04:00
Disco DeDisco
f0f419ff7e offloaded Significator FTs into FTs.test_room_sig_select; new sig-select.js imported into room.html; new apps.epic.consumers & .views, ITs to confirm functionality
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 11:03:53 -04:00
Disco DeDisco
0494710ce0 skipped a FT clogging the pipeline in need of js not yet built
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 10:26:42 -04:00
Disco DeDisco
713e24863d fixed two failing pipeline errors due to significator select; skipped two others
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 02:25:59 -04:00
Disco DeDisco
b3bc422f46 new migrations in apps.epic for .models additions, incl. Significator select order (= Start Role seat order), which cards of whom go into which deck, which are brought into Sig select; new select-sig urlpattern in .views; room.html supports this stage of game now
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 01:50:06 -04:00
Disco DeDisco
c0016418cc hopefully plugged pipeline fail for FT to assert stock card deck version; 11 new test_models ITs & 12 new test_views ITs in apps.epic.tests 2026-03-25 01:30:18 -04:00
Disco DeDisco
4d52c4f54d reordered Pope cards in Earthman deck; addressed two pipeline errors concerning card deck via setUp helper
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 01:08:12 -04:00
Disco DeDisco
db1608fa38 Earthman card naming conventions overhauled: group-relative Arabic ordinals throughout (Implicit/Explicit Virtues, Classical/Absolute Elements, Zodiac, Wanderers, Popes); group prefix + title split across two lines in fan modal via name_group/name_title model properties; 4th suit migrated COINS → PENTACLES w. fa-star icon on both decks; pip names 2–10 spelled out; Classical Element 2 renamed Earth → Stone; migrations 0012–0015
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-25 00:46:48 -04:00
Disco DeDisco
4728cde771 Jacks & Cavaliers replaced in Earthman deck w. Maids & Jacks; numerals or numbers + symbols added to cards; migrations made in apps.epic to rename cards; _tarot_fan.html partial updated accordingly 2026-03-25 00:24:26 -04:00
Disco DeDisco
2f6fc1ff20 horizontal scrolling where applicable can now be done via vertical mousewheel movement 2026-03-25 00:05:52 -04:00
Disco DeDisco
9698d70164 scroll buffer in room_scroll.html aperture fine-tuned so that 'What happens next…?' can always be reached by scrolling on a fresh page reload, even if the user was at the very end of the scroll
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-24 23:47:17 -04:00
Disco DeDisco
7370fd611f tolltips added to card deck; supported in game-kit.js, _wallet-tokens.js (we should rename this for broader concept than just wallet) 2026-03-24 23:29:32 -04:00
Disco DeDisco
f5a5ed9d8d currently equipped card deck & placeholder for dice set added to kit bag; scrollability of tokens added to styling; equipped_deck added to apps.dash.views.kit_bag; html structure added to templates/core/_partials/_kit_bag_panel.html; two new test cases added to FTs.test_game_kit.GameKitTest 2026-03-24 23:18:04 -04:00
Disco DeDisco
a5d71925fc game kit page: four 6×3 applets (trinkets, tokens, card decks, dice sets) with applet grid; tarot fan modal with coverflow, sessionStorage position memory, and 403 guard on locked decks; unlocked_decks M2M on User with backfill migration; game kit icon wrap fix; tarot_deck.html moved to gameboard/ per template dir convention (now documented in CLAUDE.md); FTs 6–13, 2 new ITs; 360 passing [log Co-Authored-By: Claude Sonnet 4.6] 2026-03-24 22:57:12 -04:00
Disco DeDisco
b03ba09b65 new migrations in apps.lyric ensure new users start only w. Earthman card deck unlocked; FTs.test_component_cards_tarot.py updated to assert that user specifically has Fiorentine deck unlocked as well
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-24 22:34:50 -04:00
Disco DeDisco
befa61e1e9 several fixes, incl. location of templates/apps/epic/tarot_deck.html to apps/gameboard/tarot_deck.html; added this convention to CLAUDE.md; Game Kit applet items now plentiful enough to bother w. text wrapping in _gameboard.scss; unlocked_decks differentiates from equipped_deck in apps.lyric.models; new migrations accordingly; apps.gameboard.views accounts for only unlocked_decks in deck_variants now; apps.epic.views redirected to new tarot_deck.html location 2026-03-24 22:25:25 -04:00
Disco DeDisco
15ac3216ff step 17 complete: game kit deck variant cards with hover-equip mini-tooltip; DeckVariant.short_key property for template ids; equip-deck view and url in gameboard; gameboard.js unified for decks and trinkets, portals now inline-display-controlled for FT compatibility; billboard scroll fix: pos captured at event time, rAF guard prevents spurious debounce reset on first visit; 3 new ITs for Earthman deck defaults, Fiorentine not auto-assigned; gameboard IT updated for deck variant cards [git log Co-Authored-By: Claude Sonnet 4.6]
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-24 21:52:57 -04:00
Disco DeDisco
2896efa8e0 long overdue fix to last pipeline push, where scroll position did not persist across sessions 2026-03-24 21:36:02 -04:00
Disco DeDisco
588358a20f added default Earthman 108-card tarot deck, 78-card Minchiate Fiorentine deck, admin tests for each; DeckVariant model governs deck toggle; ran new migrations for apps.epic, apps.lyric; seeded DeckVariant migration to ensure Earthman is default deck; added min. tarot url; most new FTs passing 2026-03-24 21:07:01 -04:00
Disco DeDisco
11c85d56d1 fixed last of scroll position view in portrait mode to remember & display user's last line at bottom of applet viewport
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-24 19:11:27 -04:00
Disco DeDisco
8bab26e003 scroll position save fix attempt no. 1 feat. 'What happens next…?' text at bottom of scroll; buffer added to scroll, accounter for in FTs 2026-03-24 19:02:29 -04:00
Disco DeDisco
bc78d2c470 offloaded templates/core/_partials/_forthcoming.html to inject in any applet or other feature under construction; used immediately in Contacts billboard applet; styles updated accordingly 2026-03-24 18:40:16 -04:00
Disco DeDisco
2447315fd3 forgot to add latest migrations from apps.drama 2026-03-24 17:45:50 -04:00
Disco DeDisco
cde231d43c billscroll should now remember user's position across devices 2026-03-24 17:44:34 -04:00
Disco DeDisco
a0f8aeb791 similar pseudo-applet styling added to _scroll.html 2026-03-24 17:31:51 -04:00
Disco DeDisco
2ca4e9d39f fixed #id_gear_btn styling on billboard.html; removed redundant padding from %billboard-page-base 2026-03-24 17:22:49 -04:00
Disco DeDisco
c71f4eb68c styled more of Most Recent applet, allowing for scrolling of 36 most recent events and Load More link 2026-03-24 17:19:09 -04:00
Disco DeDisco
189d329e76 new applet structure for apps.billboard, incl. My Scrolls, Contacts & Most Recent applets; completely revamped _billboard.scss, tho some styling inconsistencies persist; ensured #id_billboard_applets_container inherited base styles found in _applets.scss; a pair of new migrations in apps.applets to support new applet models & fields; billboard gets its first ITs, new urls & views; pair of new FT classes in FTs.test_billboard 2026-03-24 16:46:46 -04:00
Disco DeDisco
18898c7a0f several fixes to payment applet styling & script
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-24 14:13:44 -04:00
Disco DeDisco
f347af7eff reordered footer tab icons; addressed pipeline layout FT error
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-24 00:49:04 -04:00
Disco DeDisco
e59d5fd4c0 committing uncommitted styling changes from static_src/scss/
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-24 00:28:50 -04:00
Disco DeDisco
62f6c27806 many styling changes to applets and palettes applet esp.; all applets seeded w. < 3rows bumped to 3 w. new migration in apps.applets; setting palette no longer reloads entire page, only preset background-color vars; two new ITs in apps.dash.tests.ITs.test_views.SetPaletteTest to ensure dash.views functionality fires; unified h2 applet title html structure & styled its text vertically to waste less applet space
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-24 00:26:22 -04:00
Disco DeDisco
cc02419e8d actually bubbles up original error w.o pickling TypeErrors wrapping it
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-23 22:56:10 -04:00
Disco DeDisco
c331e72de6 fixed some styling issues that prevented the enter email for login field from displaying on landscape breakpoints
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-23 20:07:59 -04:00
Disco DeDisco
a1f8d294a3 several more styling fixes to get landscape FTs to pass pipeline
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-23 19:50:08 -04:00
Disco DeDisco
5607f70852 added type='button' to both guard portal btns so firefox won't normalize to type='submit'; fixed several FTs for new click-guard functionality on Role card select & room gear menu DEL & BYE btns; several restorations to landscape breakpoint incl. logged-ion display_name, copyright info; provided title to room_scroll.html; a slurry of other minor fixes
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-23 19:31:57 -04:00
Disco DeDisco
eecb6c2be6 ensured footer was pinned to bottom of page for new-ish billboard.html & room_scroll.html pages; introduced mobile landscape layout, incl. leftward 'navbar', rightward 'footer'; ensured z-index primacy of #id_kit_btn, which would here appear behind the kit bar when open; other fixes introduced by problems stemming largely from new landscape styling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-23 01:06:14 -04:00
Disco DeDisco
2fd3ec9ab2 added header_text to billboard.html; restored L+R .container padding after last fix (still 0 T+B)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-22 15:06:54 -04:00
Disco DeDisco
cad3744a57 gameboard gear menu clipping under footer aperture finally RESOLVED; .container padding attr true cause behind two red herrings, #id_footer background attr & %applets-grid mask-image attr; latter still pared down to open more viewable space in applet container aperture
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-22 14:36:02 -04:00
Disco DeDisco
ffb374c81c updated palette-classes ending in .*-light to switch the rgb values of their tooltip background-color attrs from black to white (better accessibility); changed 'monochrome-light' & its cognates to 'oblivion-light', since it's hardly monochrome at all anymore
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-21 23:57:05 -04:00
Disco DeDisco
3b905e0436 moved _scroll.html from templates/apps/drama/ to templates/core/_partials/; updated templates/apps/billboard/room_scroll.html include tag to point there
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-21 23:39:47 -04:00
Disco DeDisco
f1b5ba2a71 given flaky --parallel FT pipeline fails, new fix in core.runner, incl. _Py313SafeRemoteTestRunner, so that errors bubbling up don't read as generic TypeError: cannot pickle 'traceback' object
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-21 23:08:21 -04:00
Disco DeDisco
184854a2de new apps.epic.tests.integrated.test_views.PickRolesViewTest.test_pick_roles_idempotent_no_duplicate seats passes w. duplicate no-op post ensures single line addition to apps.epic.views.pick_roles prevents ea. position from drawing twice ea. turn during Role Select phase at table; new assertions in FTs.test_room_role_select.RoleSelectChannelsTest.test_turn_passes_after_selection for same
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-21 22:22:06 -04:00
Disco DeDisco
f5c2cf4636 in role-select.js, selectRole() runs in more precise ordering to ensure card hand for role selection passes to the next gamer after a selection is made; previous bug allowed multiple cards at a single gamer position, which prevented the card hand from making a circuit around the table before depletion; backend fixes including to apps.epic.views.select_role; +2 FTs & +1 IT asserts these features
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-21 14:33:06 -04:00
Disco DeDisco
91e0eaad8e new DRAMA & BILLBOARD apps to start provenance system; new billboard.html & _scroll.html templates; admin area now displays game event log; new CLAUDE.md file to free up Claude Code's memory.md space; minor additions to apps.epic.views to ensure new systems just described adhere to existing game views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-19 15:48:59 -04:00
Disco DeDisco
5a811d0079 plugged some test coverage lacunae, incl. tests for release_slot for the Carte Blanche; select_role for ROLE_CHOICES & ROLE_SELECT; equip_trinket non-POST paths; & tooltip_shoptalk for the Tithe Token
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-19 00:00:00 -04:00
Disco DeDisco
8c2a5d24ec updated .fa-ban icon to update via js & ws; changed taken_roles (or its cognates) everywhere to starter_roles, as 'taken' will be used in respect to roles thru-out entire game, not just this seat-determining phase of Role Select; patched up chosen cards not disappearing upon previous gamer choice, & a try,except that catches attempts to select one anyway w. a 409 & optimistic card rollback; new IT confirms this 409
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-18 23:14:53 -04:00
Disco DeDisco
4f076165ef removed console ws closed warning on event.wasClean
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-18 22:20:51 -04:00
Disco DeDisco
3a87a17017 Dockerfile updated to run uvicorn worker class to support asgi (was still gunicorn & wsgi)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-18 22:03:10 -04:00
Disco DeDisco
4e63323019 a pair of small fixes to infra/nginx.conf.j2, to ensure WebSockets functionality; & to role-select.js, to fix the inventory from not updating to that of the new position when a gamer passed the Role cards to the next position when he also occupies that position; separate inventories now ensured
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-18 21:42:59 -04:00
Disco DeDisco
8b2c4e1bdc imported tag to tag 'channels' on RoleSelectChannelsTest to see if the pipeline can get past more similar complications
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-18 21:11:07 -04:00
Disco DeDisco
10d717a3ba removed parallel worker subprocess fail screendump req'ment, so not to break the --parallel FT run
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-18 20:49:44 -04:00
Disco DeDisco
e9f50810da imported itertools to base FT fns to support --parallel core split from last push
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-18 20:42:54 -04:00
Disco DeDisco
67697fa90e established parallel CI pipeline for quicker testing after DO droplet upsizing; ensured gamearray (docker) and gamearray_celery services restart automatically when not purposefully powered off
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-18 20:24:02 -04:00
Disco DeDisco
97b406c7e0 seat-card-arc fan driven by data-card-count (0/1/2/3); active arc glows/floats;dual CSS class aliases: .table-seat/.table-position, .seat-portrait/.position-portrait etc.; seat_role_counts context var; room.html arcs populated server-side on load; per-position inventory model: assigned_seats=[] always; JS clears #id_inv_role_card on turn_changed; _notify_turn_changed includes seat_counts (str keys) for observer arc sync; selectRole() increments active arc immediately + disables stack to prevent double-picks; room.js WS auto-reconnect with exponential backoff (1s->30s); _applet_menu.html extracted from gameboard/_applets.html and wallet/_applets.html (menu now sibling of applets container, not nested inside it); partial fix for mask clip bug — deferred; commented out footer background-gradient (revealed underlying clip bug); removed landscape .room-page .gear-btn bottom override; FT 3d: assert arc data-card-count=1 on re-entry instead of inventory cards
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-17 15:48:38 -04:00
Disco DeDisco
568497d09d duplicate browsers to simulate multiple gamers in test envs now handle headless firefox in pipeline correctly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-17 01:00:15 -04:00
Disco DeDisco
1558bb02b4 fixed box-shadow attr on token equip assignation to .token-panel instead of .token-rails, where it belonged
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-17 00:39:19 -04:00
Disco DeDisco
01de6e7548 Django Channels role-select sprint: turn_changed, roles_revealed, role_select_start consumer handlers; WS URL changed from room_slug to room_id UUID; TableSeat model - room, gamer, slot_number, role, role_revealed, seat_position fields; Room.table_status field with ROLE_SELECT, SIG_SELECT, IN_GAME choices; migration 0006_table_status_and_table_seat; pick_roles and select_role views; _role_select_context helper; _notify_turn_changed, _notify_roles_revealed, _notify_role_select_start notifiers; all gate-mutation views now call _notify_gate_update; ChannelsFunctionalTest base class with serve_static, screenshot, dump helpers; SQLite TEST NAME set to file path for ChannelsLiveServerTestCase; InMemoryChannelLayer added to test CHANNEL_LAYERS settings; FT 5 and FT 6 now passing - active seat arc and turn advance via WS, no page refresh; room.js, gatekeeper.js, role-select.js added to apps/epic/static; applets.js, game-kit.js, dashboard.js, wallet.js relocated to app-scoped static dirs; room.html: hex table, table-seat arcs, card-stack, inventory panel, role-card hand, WS scripts; _room.scss: room-shell flex layout, .table-hex polygon clip-path, .table-seat and .seat-card-arc, .card-stack eligible/ineligible states, .card flip animation, .inv-role-card stacked hand, .role-select-backdrop; gear btn and room menu always position: fixed; 375 tests, 0 skipped 2026-03-17 00:24:23 -04:00
Disco DeDisco
c9defa5a81 daphne added to dependencies; still reliant on uvicorn, as the former is now used solely as a channels testing req'ment; new consumer model in apps.epic.consumers to handle _gatekeeper partial functionality, permitting access to room once token costs met; new .routing urlpattern to accomodate; new tests.integrated.test_consumer IT cases ensure this functionality 2026-03-16 18:44:06 -04:00
Disco DeDisco
462155f07b fixed some UX inconsistencies in gatekeeper
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-16 01:04:52 -04:00
Disco DeDisco
fa46fc18d7 fixes to kit bag dialog & mini-tooltip presence which stymied a pair of FTs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-16 00:30:33 -04:00
Disco DeDisco
4239245902 add Carte Blanche trinket: equip system, gatekeeper multi-slot, mini tooltip portal; new token type Token.CARTE ('carte') with fa-money-check icon; migrations 0010-0012:
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
CARTE type, User.equipped_trinket FK, Token.slots_claimed field; post_save signal sets
equipped_trinket=COIN for new users, PASS for staff; kit bag now shows only the equipped
trinket in Trinkets section; Game Kit applet mini tooltip portal shows Equipped or Equip
Trinket per token; AJAX POST equip-trinket id updates equippedId in-place; equip btn
now works for COIN, PASS, and CARTE (data-token-id added to all three); Gatekeeper CARTE
flow: drop_token sets current_room (no slot reserved); each empty slot up to
slots_claimed+1 gets a drop-token-btn; slots_claimed high-water mark advances on fill,
never decrements; highest CARTE-filled slot gets NVM (release_slot); token_return_btn
resets current_room + slots_claimed + un-fills all CARTE slots; gate_status always returns
full template so launch-game-btn persists via HTMX when gate_status == OPEN; room.html
includes gatekeeper when GATHERING or OPEN; new FT test_trinket_carte_blanche.py (2
tests, both passing); 299 tests green
2026-03-16 00:07:52 -04:00
Disco DeDisco
b49218b45b significant palette overhaul, w. addition of +3 new palettes; new swatch preview appearance; expanded palette toggle functionality; repaired test suite accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-15 18:52:09 -04:00
Disco DeDisco
ace9a4888e updated description text on Backstage Pass to more accurately describe its unlimited capacity
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-15 17:54:58 -04:00
Disco DeDisco
435bec7988 confined htmx polling on _gatekeeper.html to permit continuous typing; previous behavior kicked mobile user out of keyboard input every 3s period
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-15 17:36:42 -04:00
Disco DeDisco
12146037f0 now that like token_types stack in UX, _0 removed from 4 test methods that previously looked for specific token's ID
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-15 16:57:24 -04:00
Disco DeDisco
ff7b71792f narrow desktop breakpoint constraint relaxed somewhat to accomodate more fringe-case window aspect ratios; #id_gear_btn now, like #id_kit_btn, restyles to contain --quaUser rgb value when menu is active; dashboard.html include ordering switched for #id_dash_applet_menu & #id_gear_btn, to fix an issue causing the menu to overlay the btn instead of the other way around
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 16:39:14 -04:00
Disco DeDisco
2e24175ec8 new apps.epic app migrations for token expiration & cooldown; reject token renamed to return token everywhere; new mapps.epic.models & .views for expiration & cooldown; new apps.dash.views to manage stacking of like Token types not just in the kit bag but in the Gameboard's Game Kit applet & in the Dashwallet's Tokens applet; Free Tokens now display correctly in kit bag; apps.lyric.admin now ensures superuser cannot grant Free Tokens without an expiration date; corresponding tests in .tests.integrated.test_admin.TokenAdminFormTest; screendumps occurring for every test, regardless of passfail status, after one fail fixed in FTs.base; FTs.test_gatekeeper.GameKitInsertTest.test_free_token_insert_via_kit_consumed_on_confirm, for test purposes only, ensures starting Free Token deleted before fresh one assigned w. full 7d expiration battery 2026-03-15 16:08:34 -04:00
Disco DeDisco
18ba242647 fixed fatal pipeline flaw by correcting game-kit.js dir from static/apps/scripts to apps/dashboard/static/apps/scripts/game-kit-js; the former folder is untracked by git, so successful local code changes never registered to CI static files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-15 13:51:48 -04:00
Disco DeDisco
6d1b358b7c more pipeline troubleshooting, possible pointer-event attr solution for headless browser FTs
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 13:07:13 -04:00
Disco DeDisco
2140bd8206 changed _room.scss overflow to target html instead of body, hopefully fixing FTs in pipeline for real this time
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 02:27:10 -04:00
Disco DeDisco
52e171cb20 patched some local fails & errors; pipeline still expected to show cracks
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 02:22:07 -04:00
Disco DeDisco
74d1a43559 #id_dash_applet_menu now outside #id_applets_container to avoid clipping, other issues (FTs passed locally, but not in headless CI pipeline); selenium now calls wait_for when looking for is_displayed on kit bag menu (hopefully another CI fix)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 01:46:11 -04:00
Disco DeDisco
2d453dbc78 new _kit_bag_panel.html partial in core to allow user to manage equipped kit items from anywhere on site; #id_kit_btn moved from _footer.html partial directly into a base.html include; new trinket for superusers now incl. in apps.lyric.models; apps.gameboard.views handles this new type of PASS token; apps.epic.views allows payment with several different token types based on rarity & expiration hierarchy; kit bag and PASS functionality now handled in apps.dashboard.views; /kit-bag/ now pathed in .urls; styles abound; fully passing test suite (tho much work to be done, chiefly with stacking like coins in FEFO order)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-15 01:17:09 -04:00
Disco DeDisco
4baaa63430 new model fields & migrations for apps.epic & apps.lyric; new FTs, ITs & UTs passing
; some styling changes effected primarily to _gatekeetper.html modal
2026-03-14 22:00:16 -04:00
Disco DeDisco
26b6d4e7db fixed invite input field timeout, which would obey the refresh triggered by the modal every 3s
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-14 13:32:56 -04:00
Disco DeDisco
f4dfce826b filled some styling lacunae, including structural fixes to html re: gatekeeper gear menu
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-14 13:28:31 -04:00
Disco DeDisco
53d9f79476 fixed css class mismatch for coin slot token rejection, left from unevenly applied refactor in last push; pipeline should now be green
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-14 11:01:12 -04:00
Disco DeDisco
ed48d18c1d selector button.token-rails replaces .token-insert-btn to fix 8 broken FTs clogging the pipeline
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-14 02:25:51 -04:00
Disco DeDisco
f76c6d0fe5 various styling & structural changes to unify site themes; token-drop interaction changes across epic urls & views
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-14 02:03:44 -04:00
Disco DeDisco
d9feb80b2a js snippet displays dynamic ellipsis on loading-style token gatekeeper modals; tweaks to existing pythonic & test structure to accomodate 2026-03-14 01:14:05 -04:00
Disco DeDisco
d780115515 fixed modal UX issue; now persists as intended, until token cost met in all six slots 2026-03-14 00:34:07 -04:00
Disco DeDisco
af3523c9bb new _room_gear.html to manage room actions for various gamers (e.g., founders & guests); new _room.scss for gatekeeper styling (still flimsy); added new .btn-abandon Bl-btn palette to _button-pad.scss; new FTs & epic view ITs assert functionality (100 percent coverage, fully passing test suite) 2026-03-14 00:10:40 -04:00
Disco DeDisco
dddffd22d5 covered some test lacunae; gatekeeper now waits for +6 gamers to commit tokens to unblock game room 2026-03-13 22:51:42 -04:00
Disco DeDisco
e0d1f51bf1 new migrations in apps.epic app; new models, urls, views handle the founder of a New Game inviting a friend via email to a game gatekeeper; ea. may drop coin in any of up to 6 avail. slots; FTs & ITs passing 2026-03-13 18:37:19 -04:00
Disco DeDisco
6a42b91420 new migrations in apps.epic & apps.lyric apps; new Token fields of latter articulate upon Room model helper fns of former; new FTs, ITs & UTs capture new behavior accordingly; new template partial content in templates/apps/gameboard 2026-03-13 17:31:52 -04:00
Disco DeDisco
5773462b4c massive additions made thru somewhat new apps.epic.models, .urls, .views; new html page & partial in apps/gameboard; new apps.epic FT & ITs (all green); New Game applet now actually leads to game room feat. token-drop gatekeeper mechanism intended for 6 gamers 2026-03-13 00:31:17 -04:00
Disco DeDisco
681a1a4cd0 seeded apps.epic for backend gameboard logic; core.asgi & .settings now accomodate Channels via Redis; several new libraries in reqs to accomodate 2026-03-12 15:05:02 -04:00
Disco DeDisco
69fea65bf9 new core.runner helper to avoid local caching issues w. coverage tests; .settings, apps.dash.tests.ITs.test_wallet_views updated accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-12 14:23:09 -04:00
Disco DeDisco
068b99d030 added missing dunderinits to apps.applets.tests & .tests.integrated; some of the test_models ITs never were passing til now but never tested either; new apps.lyric.tests.integrated.test_models cover missing Applet model return
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-11 15:53:31 -04:00
Disco DeDisco
8807d31274 unified header_title template values across dashboard applet destination pages; styled &/ added applet titles across all applets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-11 14:50:08 -04:00
Disco DeDisco
50ee983e27 found some lingering List references in the template dir; summarily changed to Note 2026-03-11 14:10:56 -04:00
Disco DeDisco
f45740d8b3 renamed List to Note everywhere thru-out project in preparation for complete overhaul of applet capabilities 2026-03-11 13:59:43 -04:00
Disco DeDisco
aa1cef6e7b new migration in apps.applets to seed wallet applet models; many expanded styles in wallet.js, chiefly concerned w. wallet-oriented FTs tbh; some intermittent Windows cache errors quashed in dash view ITs; apps.dash.views & .urls now support wallet applets; apps.lyric.models now discerns tithe coins (available for purchase soon); new styles across many scss files, again many concerning wallet applets but also applets more generally and also unorthodox media query parameters to make UX more usable; a slew of new wallet partials
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-11 00:58:24 -04:00
Disco DeDisco
791510b46d many styling fixes, esp. for both landscape & portrait mobile UX tooltips & navbar; core.settings now permits another device on local net to access dev server
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-10 14:11:53 -04:00
Disco DeDisco
fe6d2c5db1 stylistic changes primarily, esp. to page titles(new spans in header_text block, for instance)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-10 01:25:07 -04:00
Disco DeDisco
d2861077a4 tooltips now fully styled, appearing above applet container to avoid clipping issues; new methods added to apps.lyric.models.Token 2026-03-09 23:48:20 -04:00
Disco DeDisco
645b265c80 several user QoL styling improvements, incl. footer icon .active color painting 2026-03-09 22:42:30 -04:00
Disco DeDisco
382dd5958f full test suite passes; .gear-btn once again moved, this time to new file _applets.scss, along with generic applet styling attrs (removed from _base & .dash, respectively); _gameboard.scss in many ways mirrors particularities of _dash, but also feat. style attrs for the Game Kit applet consumables array; sacrificed btn in the latter now that applet dimensions defined on gameboard.html
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-09 21:52:54 -04:00
Disco DeDisco
47d84b6bf2 extensive refactor push to continue to liberate applets from dashboard; new _applets.html & .gear.html template partials for use across all -board views; all applets.html sections have been liberated into their own _applet-<applet-name>.html template partials in their respective templates/apps/*board/_partials/ dirs; gameboard.html & home.html greatly simplified; .gear-btn describes gear menu now, #id_<*board nickname>*gear IDs abandoned; as such, .gear-btn styling moved from _dashboard.scss to _base.scss; new applets.js file contains related initGearMenus scripts, which no longer waits for window reload; new apps.applets.utils file manages applet_context() fn; new gameboard.js file but currently empty (false start); updates across all sorts of ITs & dash- & gameboard FTs 2026-03-09 21:13:35 -04:00
Disco DeDisco
97601586c5 new applets app for cross-board usage of Applet() & UserApplet() models; dashboard migrations reset and apps reseeded w. new default specs; core.settings & many tests thru-out suite updated accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-09 16:08:28 -04:00
Disco DeDisco
2c445c0e76 replaced gear alt char or emoji w. font-awesome placeholder
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-09 15:09:41 -04:00
Disco DeDisco
a53dc41367 unified some styles, especially in #id_dash_gear menu
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-09 14:57:39 -04:00
Disco DeDisco
251b3bf778 commenced wallet styling; much of site now holds font-awesome placeholders until proprietary svg files apprpriated
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-09 14:40:34 -04:00
Disco DeDisco
bb2116ae9f stripe authentication error hopefully fixed w. woodpecker.ci .env var references
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-09 01:16:55 -04:00
Disco DeDisco
bd72135a2f full passing test suite w. new stripe integration across multiple project nodes; new gameboard django app; stripe in test mode on staging
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-09 01:07:16 -04:00
Disco DeDisco
ad0caa7c17 new migration to add wallet applet to dash db table; new views & html to accomodate 2026-03-08 15:27:24 -04:00
Disco DeDisco
076d75effe new apps/dashboard/wallet.html for stripe payment integration and user's consumables; nav added to _footer.html & also dynamic copyright year with django now Y template; new apps.dash.tests ITs & UTs reflect new wallet functionality in .urls & .views 2026-03-08 15:14:41 -04:00
Disco DeDisco
571f659b19 two new FTs, neither yet passing; test_wallet drives Stripe integration; test_gameboard drives Token system & apps.gameboard creation 2026-03-08 01:52:03 -05:00
Disco DeDisco
10dbd07cb9 fixed some breakpoint styling that prevented scrolling on mobile landscape windows
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-07 15:34:32 -05:00
Disco DeDisco
314da3e246 major styling additions & refinements; offloaded navbar from base.html into its own partial, core/_partials/_navbar.html, alongside new _footer.html; 0006 dash migrations fix 0003 & 0005 theme-switcher handling and rename more fluidly to palette; added remaining realm-swatches to palette applet choices & updated test_views accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-07 15:05:49 -05:00
Disco DeDisco
672de8a994 removed dead code from _applets.html
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-07 00:17:52 -05:00
Disco DeDisco
13940ca834 mobile dash layout provided; other styling inconsistencies corrected across views, scss & _applets.html template partial
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-07 00:05:32 -05:00
Disco DeDisco
b5d6912b26 styling & structure fixes to apps/dash/_parts/_applets.html, _dash.scss & _palette-picker.scss
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 23:12:56 -05:00
Disco DeDisco
02d0adef78 styling & subsequent testing bugs fixed across apps.dash.tests.ITs.test_views, functional_tests.test_dashboard,_dashboard.scss & apps/dash/_partials/_applets.html
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 22:31:10 -05:00
Disco DeDisco
4c502e40f8 fixed applet seeding in 0005 migration; many FTs & ITs now require authentication before they pass; New List & My Lists converted to dash applets; home.html offloaded and _applets.html onboarded w. these applets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 21:34:43 -05:00
Disco DeDisco
17ee6c1f08 slight scss tweaks to palette applet
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 19:32:36 -05:00
Disco DeDisco
86e70b7256 took db-breaking migrations change out of 0003 and placed into new migration 0005 (grid_cols, grid_rows)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 19:22:30 -05:00
Disco DeDisco
9aea1ccb56 updated applet seed migration to include default applet sizes; other sundry styling refinements
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-06 19:14:53 -05:00
Disco DeDisco
42a9049c0a new migration in apps.dashboard for Applet grid_cols & grid_rows settings; test_models; complete overhaul of _dashboard.scss to containerize user scrolling; some new styling in _base.scss supports static window behind localized scrolling; new applet mgmt in apps.dashboard.admin; .views passes page_dashboard to home_page() FBV; keep an eye on IT apps.dashboard.tests.integrated.test_views.NewListTest.test_for_invalid_input_renders_list_template for intermittent caching errors
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 18:14:01 -05:00
Disco DeDisco
9936275443 significant expansion of scss styling, incl. new _dashboard.scss sheet & comprehensive primary btn theme synced w. user palette; changes to all other scss files; list.html & base.html retrofitted w. corresponding scss classes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-06 16:39:05 -05:00
Disco DeDisco
20c5f6f589 new _applets partial to govern applet list; home.html updated accordingly to incl partial; fixed seed migrations for palette convention from last commit; new text_view ITs & views to govern applet visibility/toggling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-05 16:08:40 -05:00
Disco DeDisco
c099479740 'theme_switcher,' 'theme-picker' & 'theme' renamed everywhere to simply 'palette'; new urls & views & their corresponding ITs ensure applet menu checkbox functionality 2026-03-05 14:45:55 -05:00
Disco DeDisco
ca835059c2 new migrations; new models in apps.dash for Applets and UserApplets; new ITs to match 2026-03-04 15:43:24 -05:00
Disco DeDisco
9548a2cd15 added locally hosted htmx dependency; updated base.html template & req's files accordingly; wrote new FT (failing) in test_dashboard that calls for this lib 2026-03-04 15:13:16 -05:00
Disco DeDisco
a218391ea5 100 percent test coverage achieved, patching a critical api bug in api.serializers and .views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-04 13:40:19 -05:00
Disco DeDisco
fd59b02c3a new test_dashboard FT (part 1) for username applet on dashboard; apps/dashboard/home.html gained new applet section to support additions; new urlpatterns in apps.dash.urls; tweaks to .views, including the @login_required decorator and set_profile() FBV; new ITs in .tests.integrated.test_views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-04 00:07:10 -05:00
Disco DeDisco
649bd39df9 didn't actually add any new files connected to lyric.templatetags
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-03 19:07:45 -05:00
Disco DeDisco
1c894f8ae6 username truncation functionality added
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-03 16:10:49 -05:00
Disco DeDisco
105b8f1e34 buttressed ansible playbook for automatic ssl certification
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-03 14:18:21 -05:00
Disco DeDisco
06f85d4c54 passed dummy values into compress command in Dockerfile for quick pipeline fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-02 22:23:58 -05:00
Disco DeDisco
b53c0b9849 small compress fixes to help serve scss on staging server and avoid persistent 500 errors
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-03-02 16:02:47 -05:00
Disco DeDisco
eebc355f95 themes initialized! many new partials and scss integrations across most templates; core.settings contains COMPRESS test fallback; apps.dashboard.views updated for new alerts and styling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-03-02 15:45:12 -05:00
Disco DeDisco
e142e5d4d7 new FT test_theme for theme switcher functionality; theme-switcher content added to home.html, several dashboard views & urls, all appropriate ITs & UTs; lyric user model saves theme (migrations run); django-compressor and django-libsass libraries added to dependencies 2026-03-02 13:57:03 -05:00
295 changed files with 41364 additions and 598 deletions

5
.gitignore vendored
View File

@@ -10,9 +10,8 @@
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
container.db.sqlite3
*.sqlite3
*.sqlite3-journal
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/

View File

@@ -23,17 +23,40 @@ steps:
when:
- event: push
- name: test-two-browser-FTs
image: gitea.earthmanrpg.me/discoman/python-tdd-ci:latest
environment:
HEADLESS: 1
CELERY_BROKER_URL: redis://redis:6379/0
REDIS_URL: redis://redis:6379/1
STRIPE_SECRET_KEY:
from_secret: stripe_secret_key
STRIPE_PUBLISHABLE_KEY:
from_secret: stripe_publishable_key
commands:
- pip install -r requirements.txt
- cd ./src
- python manage.py collectstatic --noinput
- python manage.py test functional_tests --tag=two-browser
- python manage.py test functional_tests --tag=channels
when:
- event: push
- name: test-FTs
image: gitea.earthmanrpg.me/discoman/python-tdd-ci:latest
environment:
HEADLESS: 1
CELERY_BROKER_URL: redis://redis:6379/0
REDIS_URL: redis://redis:6379/1
STRIPE_SECRET_KEY:
from_secret: stripe_secret_key
STRIPE_PUBLISHABLE_KEY:
from_secret: stripe_publishable_key
commands:
- pip install -r requirements.txt
- cd ./src
- python manage.py collectstatic --noinput
- python manage.py test functional_tests
- python manage.py test functional_tests --parallel --exclude-tag=channels --exclude-tag=two-browser
when:
- event: push

148
CLAUDE.md Normal file
View File

@@ -0,0 +1,148 @@
# EarthmanRPG — Project Context
Originally built following Harry Percival's *Test-Driven Development with Python* (3rd ed., complete through ch. 25). Now an ongoing game app — EarthmanRPG — extended well beyond the book.
## Browser Integration
**Claudezilla** is installed — a Firefox extension + native host that lets Claude observe and interact with the browser directly.
### Tool names
Tools are available as `mcp__claudezilla__firefox_*`, e.g.:
- `mcp__claudezilla__firefox_screenshot` — capture current tab
- `mcp__claudezilla__firefox_navigate` — navigate to URL
- `mcp__claudezilla__firefox_get_page_state` — structured JSON (faster than screenshot)
- `mcp__claudezilla__firefox_create_window` — open new tab (returns `tabId`)
- `mcp__claudezilla__firefox_diagnose` — check connection status
- `mcp__claudezilla__firefox_set_private_mode` — disable private mode to use session cookies
All tools require a `tabId` except `firefox_create_window` and `firefox_diagnose`.
### If tools aren't available in a session
MCP servers load at session startup only. **Start a new Claude Code conversation** (hit "+" in the sidebar) — no need to reboot VSCode, just open a fresh chat. Always call `firefox_diagnose` first to confirm the connection is live.
### Correct startup sequence
1. Firefox open with Claudezilla extension active (native host must be running)
2. Open a new Claude Code conversation → tools appear as `mcp__claudezilla__firefox_*`
3. Call `firefox_diagnose` to confirm before depending on any tool
### Setup (already done — for reference)
The native messaging host requires a `.bat` wrapper on Windows (Firefox can't execute `.js` directly):
- Wrapper: `E:\ClaudeLibrary\claudezilla\host\claudezilla.bat` — contains `@echo off` / `node "%~dp0index.js" %*`
- Manifest: `C:\Users\adamc\AppData\Roaming\claudezilla\claudezilla.json` — points to the `.bat` file
- Registry: `HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\claudezilla` → manifest path
- MCP server: registered in `~/.claude.json` (NOT `~/.claude/settings.json` or `~/.claude/mcp.json`) — use the CLI to register:
```
claude mcp add --scope user claudezilla "D:/Program Files/nodejs/node.exe" "E:/ClaudeLibrary/claudezilla/mcp/server.js"
```
- Permission: `mcp__claudezilla__*` in `~/.claude/settings.json` `permissions.allow`
**Config file gotcha:** The Claude Code CLI and VSCode extension read user-level MCP servers from `~/.claude.json` (home dir, single file) — NOT from `~/.claude/settings.json` or `~/.claude/mcp.json`. Always use `claude mcp add --scope user` to register; never hand-edit. Verify registration with `claude mcp list`.
**BOM gotcha:** PowerShell writes JSON files with a UTF-8 BOM, which causes `JSON.parse` to throw. Never use PowerShell `Set-Content` to write any Claude config JSON — use the Write tool or the CLI instead.
Native host: `E:\ClaudeLibrary\claudezilla\host\`. Extension: `claudezilla@boot.industries`.
## Stack
- **Python 3.13 / Django 6.0 / Django Channels** (ASGI via Daphne/uvicorn)
- **Celery + Redis** (async email, channel layer)
- **django-compressor + SCSS** (`src/static_src/scss/core.scss`)
- **Selenium** (functional tests) + Django test framework (integration/unit tests)
- **Stripe** (payment, sandbox only so far)
- **Hosting:** DigitalOcean staging (`staging.earthmanrpg.me`) | CI: Gitea + Woodpecker
## Project Layout
The app pairs follow a tripartite structure:
- **1st-person** (personal UX): `lyric` (backend — auth, user, tokens) · `dashboard` (frontend — notes, applets, wallet UI)
- **3rd-person** (game table UX): `epic` (backend — rooms, gates, role select, game logic) · `gameboard` (frontend — room listing, gameboard UI)
- **2nd-person** (inter-player events): `drama` (backend — activity streams, provenance) · `billboard` (frontend — provenance feed, embeddable in dashboard/gameboard)
```
src/
apps/
lyric/ # auth (magic-link email), user model, token economy
dashboard/ # Notes (formerly Lists), applets, wallet UI [1st-person frontend]
epic/ # rooms, gates, role select, game logic [3rd-person backend]
gameboard/ # room listing, gameboard UI [3rd-person frontend]
drama/ # activity streams, provenance system [2nd-person backend]
billboard/ # provenance feed, embeds in dashboard/gameboard [2nd-person frontend]
api/ # REST API
applets/ # Applet model + context helpers
core/ # settings, urls, asgi, runner
static_src/ # SCSS source
templates/
functional_tests/
```
### Template directory convention
Templates live under `templates/apps/<frontend-app>/`, not under the backend app that owns the view logic. Specifically:
- `lyric/` views → `templates/apps/dashboard/`
- `epic/` views → `templates/apps/gameboard/`
- `drama/` views → `templates/apps/billboard/`
Backend apps (`lyric`, `epic`, `drama`) have **no** `templates/` subdirectory.
## Dev Commands
```bash
# Dev server (ASGI — required for WebSockets; no npm/webpack build step)
cd src
uvicorn core.asgi:application --host 0.0.0.0 --port 8000 --reload --app-dir src
# Integration + unit tests only (from project root — targets src/apps, skips src/functional_tests)
python src/manage.py test src/apps
# Functional tests only
python src/manage.py test src/functional_tests
# All tests (integration + unit + FT)
python src/manage.py test src
```
**Test tags:** The only tag in use is `channels` — for async consumer tests that require a live Redis channel layer.
- Exclude channels tests: `python src/manage.py test src/apps --exclude-tag=channels`
- Channels tests only: `python src/manage.py test src/apps --tag=channels`
FTs are isolated by **directory path** (`src/functional_tests/`), not by tag.
Test runner is `core.runner.RobustCompressorTestRunner` — handles the Windows compressor PermissionError by deleting stale CACHE at startup + monkey-patching retry logic.
## CI/CD
- Git remote: `git@gitea:discoman/python-tdd.git` (port 222, key `~/.ssh/gitea_keys/id_ed25519_python-tdd`)
- Gitea: `https://gitea.earthmanrpg.me` | Woodpecker CI: `https://ci.earthmanrpg.me`
- Push to `main` triggers Woodpecker → deploys to staging
## SCSS Import Order
`core.scss`: `rootvars → applets → base → button-pad → dashboard → gameboard → palette-picker → room → billboard → game-kit → wallet-tokens`
## Critical Gotchas
### TransactionTestCase flushes migration data
FTs use `TransactionTestCase` which flushes migration-seeded rows. Any IT/FT `setUp` that needs `Applet` rows must call `Applet.objects.get_or_create(slug=..., defaults={...})` — never rely on migration data surviving.
### Static files in tests
`StaticLiveServerTestCase` serves via `STATICFILES_FINDERS` only — NOT from `STATIC_ROOT`. JS/CSS that lives only in `src/static/` (STATIC_ROOT, gitignored) is a silent 404 in CI. All app JS must live in `src/apps/<app>/static/` or `src/static_src/`.
### msgpack integer key bug (Django Channels)
`channels_redis` uses msgpack with `strict_map_key=True` — integer dict keys in `group_send` payloads raise `ValueError` and crash consumers. Always use `str(slot_number)` as dict keys.
### Multi-browser FTs in CI
Any FT opening a second browser must pass `FirefoxOptions` with `--headless` when `HEADLESS` env var is set. Bare `webdriver.Firefox()` crashes in headless CI with `Process unexpectedly closed with status 1`.
### Selenium + CSS text-transform
Selenium `.text` returns visually rendered text. CSS `text-transform: uppercase` causes `assertIn("Test Room", body.text)` to fail. Assert against the uppercased string or use `body.text.upper()`.
### Tooltip portal pattern
`mask-image` on grid containers clips `position: absolute` tooltips. Use `#id_tooltip_portal` (`position: fixed; z-index: 9999`) at page root. See `gameboard.js` + `wallet.js`.
### Applet menus + container-type
`container-type: inline-size` creates a containing block for all positioned descendants — applet menus must live OUTSIDE `#id_applets_container` to be viewport-fixed.
### ABU session auth
`create_pre_authenticated_session` must set `HASH_SESSION_KEY = user.get_session_auth_hash()` and hardcode `BACKEND_SESSION_KEY` to the passwordless backend string.
### Magic login email mock paths
- View tests: `apps.lyric.views.send_login_email_task.delay`
- Task unit tests: `apps.lyric.tasks.requests.post`
- FTs: mock both with `side_effect=send_login_email_task`
## Teaching Style
User prefers guided learning: describe what to type and why, let them write the code, then review together. But for now, given user's accelerated timetable, please respond with complete code snippets for user to transcribe directly.

View File

@@ -15,7 +15,9 @@ RUN python manage.py collectstatic --noinput
ENV DJANGO_DEBUG_FALSE=1
RUN DJANGO_SECRET_KEY=build-dummy DJANGO_ALLOWED_HOST=localhost python manage.py compress
RUN adduser --uid 1234 nonroot
USER nonroot
CMD ["gunicorn", "--bind", ":8888", "core.wsgi:application"]
CMD ["gunicorn", "--bind", ":8888", "-k", "uvicorn.workers.UvicornWorker", "core.asgi:application"]

View File

@@ -129,6 +129,7 @@
image: gitea.earthmanrpg.me/discoman/gamearray:latest
state: started
recreate: true
restart_policy: unless-stopped
env:
DJANGO_DEBUG_FALSE: "1"
DJANGO_SECRET_KEY: "{{ secret_key.content | b64decode }}"
@@ -150,6 +151,7 @@
image: gitea.earthmanrpg.me/discoman/gamearray:latest
state: started
recreate: true
restart_policy: unless-stopped
env:
DJANGO_DEBUG_FALSE: "1"
DJANGO_SECRET_KEY: "{{ secret_key.content | b64decode }}"

View File

@@ -12,6 +12,7 @@ docker rm gamearray 2>/dev/null || true
echo "==> Starting new container..."
docker run -d --name gamearray \
--restart unless-stopped \
--env-file /opt/gamearray/gamearray.env \
--network gamearray_net \
-p 127.0.0.1:8888:8888 \
@@ -23,6 +24,7 @@ docker rm gamearray_celery 2>/dev/null || true
echo "==> Starting new celery worker..."
docker run -d --name gamearray_celery \
--restart unless-stopped \
--env-file /opt/gamearray/gamearray.env \
--network gamearray_net \
"$IMAGE" python -m celery -A core worker -l info

View File

@@ -5,6 +5,8 @@ DJANGO_SUPERUSER_EMAIL={{ django_superuser_email }}
DJANGO_SUPERUSER_PASSWORD={{ django_superuser_password }}
DATABASE_URL=postgresql://gamearray:{{ postgres_password }}@gamearray_postgres/gamearray
MAILGUN_API_KEY={{ mailgun_api_key }}
STRIPE_PUBLISHABLE_KEY={{ stripe_publishable_key }}
STRIPE_SECRET_KEY={{ stripe_secret_key }}
CELERY_BROKER_URL=redis://gamearray_redis:6379/0
REDIS_URL=redis://gamearray_redis:6379/1

View File

@@ -1,28 +1,42 @@
$ANSIBLE_VAULT;1.1;AES256
65383061626464353936363564313761663834646361326362613934363565623234636337313363
3933313962643261353830333463336166393030313936370a616234626135633432613366633363
61633265363937326231623365646336333737306634646335376135633031643564666164336230
3435353764383936620a396165386538666433356166383661323037333861373632376432313332
66666236373462363236663335623734633364653539323331396361613738636166323134386466
66656431663261633036333537373336643866623236643139656662333831366435373837656262
36333734376363373462643239623437623735373935633732343639313666663436616630363933
61396530336461393064323161666537646135383462383532363932326132363331633438313138
61623431326537313637626239653038353263313731303262653537316134383264616661623962
32333564366362383431336432303964663835363365636434303332613161363930333065336637
33343466343062306434663765613837343635386630326439303739616166396134393939626434
62336634303963653230626630636363343730623734626336363039623231633532653330646366
66613432633834393133386666623466326131386633303264333766306135623337353433306632
66323733373232383862646661313966366465333463366361366337656537623562613964666631
65373566316432383134666434393338626138363632633766636561383263333636623530326664
63333265366132376437396431393535323931383637323833303839336635633735333565333530
65343263373630633063383931646163323237643436366566363932646566323539373136646433
37623638333834373537316164633166633738333363656431356163623332396631353864333333
33306666646532626636376239326438373737383432663539333736363866663938396136383035
32343534613862653538346430313338326435356230636535343464666262626663376635363835
65363862663461353464313533313333323863313539643533343431643130383663656161616131
33323639333564383830346163386362386238323936393832623961646565613961356263356365
65376431666130356564666236383764316136326366666661326538653133343165326431393564
36303065366263316232663230343137333231346538633036613066643365616331336135376461
35613265623134663633303238366363336137383436663836353863623533396236666433303738
38356361653633323065303035376664326238633066623731623436333332373363636634323433
393631303539373234386465663630316335
38383061343764656262613934313230656462366163363263653462333338333863326338343838
3664646437643462346636623231633639396239333532340a363338313839353734326238643735
39343237396433336436366430626332343666666461613636656433363838613432393539386266
3237336434346333350a663530623334633438616135376437666631313064333735653633396461
31306163343838336465626663373661343839653037333235313361633335646337353339616333
35343233346562346236636364316265313936646235373866636333353866623161663935626637
31633864366339653930626365373237326531366632626337636163333266656434323063333365
38373437383261613439306666373764633737623466626235356465636365646337306534326535
36633866663161613632613434666134343465383663633165663330376535653537333763376232
61653265303134656338393033303834663630653064666134633638393235346631346461633030
35343332393961363361613661633633613262663231366236396663636239326534373134623762
30653139333134616236666238616466633733656633326331386138363839653566333434346534
63326539333461383265316332336333656365386531393630663537363365643061363263313738
37633564363533633762393736636333306433306534393539636231656162343562383232663932
62646339363266303564383438636636373661656465666663613863396639633732636635326166
39323738303338373466366236623665633538363134616565326665386564613735393638656630
31326431316163376132623064376634643737313864336464623431333834663361336133353838
32303635663261333732306137383133623134373363613837306637663566303634653863343766
33613936626362653466333537666462373633313038376565623363666631353162643634653730
30323532623261643136666237316561353038323265303930336364633731333533386563623133
31343965643336613933663431626435333235366639363334653065303434386165333739336632
61363030376664643638653365626365623936623864666663326534343863613962616431376666
39363837386639393235316339323932326466616330303165613032663637616232656162653335
61613266376262626234383135306238313366346330656333383465383861663962653638303362
34353833646461383839386238626661346263363131643438343461393739336132386466373665
32646238633161363064666335626639653335306236613866333934646366323564306133396131
36343032623964316138386538333863363530396330646431373466646538663063326330663639
32323762356632336364333162336133336335623865323861663131626232633066643238333237
32343938353166353037316162653832663433343534626331633936633866356666653932656665
38396533356131326262633431653435306362633966383531356236396639376437396333616130
35666435393461316232323234653865346338326330623065373461323961393663306262313066
30313430353065616230356135333565333338373663643434353561363438656233383739663233
35653832353062396634613832353837333835636461616234343462626239636634613430373931
31656534343764643065643733326637343631356633653531313062633362663461313732633331
35626364393563373339636466346339383032383635303865306636623737343237333863353238
63306132396262656365323833323635633563653735366630313363386236613231346339643430
63396230353566633830383932666335373665356434656438336338633035653465613665613862
31663565653338376662323866613538363566306635333735646363363730646331306234353839
30346363393231623563646439623261643634663831313338393761343865303930373133633733
31656466303365316164396463373335396464643130643337656361333339653238333633373662
6539

View File

@@ -1,5 +1,5 @@
[staging]
staging.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd
staging.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd letsencrypt_domain=staging.earthmanrpg.me
[production]
www.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd

View File

@@ -1,6 +1,15 @@
server {
listen 80;
server_name {{ django_allowed_host | replace(',', ' ')}};
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name {{ django_allowed_host | replace(',', ' ') }};
ssl_certificate /etc/letsencrypt/live/{{ letsencrypt_domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ letsencrypt_domain }}/privkey.pem;
location /static/ {
alias /var/www/gamearray/static/;
@@ -8,9 +17,12 @@ server {
location / {
proxy_pass http://127.0.0.1:8888;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto https;
}
}

View File

@@ -2,11 +2,18 @@ asgiref==3.11.0
attrs==25.4.0
certifi==2025.11.12
cffi==2.0.0
channels
channels-redis
charset-normalizer==3.4.4
coverage
cryptography
cssselect==1.3.0
daphne
dj-database-url
Django==6.0
django-compressor
django-htmx
django-libsass
django-stubs==5.2.8
django-stubs-ext==5.2.8
djangorestframework
@@ -18,17 +25,21 @@ outcome==1.3.0.post0
packaging==25.0
pycparser==2.23
PySocks==1.7.1
python-dotenv
requests==2.32.5
scipy
selenium==4.39.0
sniffio==1.3.1
sortedcontainers==2.4.0
sqlparse==0.5.5
stripe
trio==0.32.0
trio-websocket==0.12.2
types-PyYAML==6.0.12.20250915
typing_extensions==4.15.0
tzdata==2025.3
urllib3==2.6.2
uvicorn[standard]
websocket-client==1.9.0
whitenoise==6.11.0
wsproto==1.3.2

View File

@@ -1,7 +1,14 @@
celery
cryptography
channels
channels-redis
cssselect==1.3.0
daphne
Django==6.0
dj-database-url
django-compressor
django-htmx
django-libsass
django-stubs==5.2.8
django-stubs-ext==5.2.8
djangorestframework
@@ -10,4 +17,7 @@ lxml==6.0.2
psycopg2-binary
redis
requests==2.31.0
scipy
stripe
whitenoise==6.11.0
uvicorn[standard]

View File

@@ -3,6 +3,7 @@ source = apps
omit =
*/migrations/*
*/tests/*
*/routing.py
[report]
show_missing = true

0
src/apps/ap/__init__.py Normal file
View File

7
src/apps/ap/apps.py Normal file
View File

@@ -0,0 +1,7 @@
from django.apps import AppConfig
class ApConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.ap"
label = "ap"

View File

View File

View File

@@ -0,0 +1,119 @@
import json
from django.test import TestCase
from apps.drama.models import GameEvent, record
from apps.epic.models import Room
from apps.lyric.models import User
class WebFingerTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="actor@test.io", username="actor")
def test_returns_jrd_for_known_user(self):
response = self.client.get(
"/.well-known/webfinger",
{"resource": "acct:actor@earthmanrpg.me"},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response["Content-Type"], "application/jrd+json")
def test_jrd_links_to_actor_url(self):
response = self.client.get(
"/.well-known/webfinger",
{"resource": "acct:actor@earthmanrpg.me"},
)
data = json.loads(response.content)
hrefs = [link["href"] for link in data["links"]]
self.assertTrue(any("/ap/users/actor/" in href for href in hrefs))
def test_returns_404_for_unknown_user(self):
response = self.client.get(
"/.well-known/webfinger",
{"resource": "acct:nobody@earthmanrpg.me"},
)
self.assertEqual(response.status_code, 404)
def test_returns_400_for_missing_resource(self):
response = self.client.get("/.well-known/webfinger")
self.assertEqual(response.status_code, 400)
class ActorViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="actor@test.io", username="actor")
def test_returns_200_for_known_user(self):
response = self.client.get("/ap/users/actor/")
self.assertEqual(response.status_code, 200)
def test_returns_activity_json_content_type(self):
response = self.client.get("/ap/users/actor/")
self.assertEqual(response["Content-Type"], "application/activity+json")
def test_actor_has_required_fields(self):
response = self.client.get("/ap/users/actor/")
data = json.loads(response.content)
self.assertEqual(data["type"], "Person")
self.assertIn("id", data)
self.assertIn("outbox", data)
self.assertIn("publicKey", data)
def test_requires_no_authentication(self):
# AP Actor endpoints must be publicly accessible
self.client.logout()
response = self.client.get("/ap/users/actor/")
self.assertEqual(response.status_code, 200)
def test_returns_404_for_unknown_user(self):
response = self.client.get("/ap/users/nobody/")
self.assertEqual(response.status_code, 404)
class OutboxViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="actor@test.io", username="actor")
self.room = Room.objects.create(name="Test Room", owner=self.user)
record(
self.room, GameEvent.SLOT_FILLED, actor=self.user,
slot_number=1, token_type="coin",
token_display="Coin", renewal_days=7,
)
record(
self.room, GameEvent.ROLE_SELECTED, actor=self.user,
role="PC", slot_number=1, role_display="Player",
)
# INVITE_SENT is unsupported — should be excluded from outbox
record(self.room, GameEvent.INVITE_SENT, actor=self.user)
def test_returns_200(self):
response = self.client.get("/ap/users/actor/outbox/")
self.assertEqual(response.status_code, 200)
def test_returns_activity_json_content_type(self):
response = self.client.get("/ap/users/actor/outbox/")
self.assertEqual(response["Content-Type"], "application/activity+json")
def test_outbox_is_ordered_collection(self):
response = self.client.get("/ap/users/actor/outbox/")
data = json.loads(response.content)
self.assertEqual(data["type"], "OrderedCollection")
def test_total_items_excludes_unsupported_verbs(self):
response = self.client.get("/ap/users/actor/outbox/")
data = json.loads(response.content)
# 2 supported events (SLOT_FILLED + ROLE_SELECTED); INVITE_SENT excluded
self.assertEqual(data["totalItems"], 2)
def test_requires_no_authentication(self):
self.client.logout()
response = self.client.get("/ap/users/actor/outbox/")
self.assertEqual(response.status_code, 200)
def test_returns_404_for_unknown_user(self):
response = self.client.get("/ap/users/nobody/outbox/")
self.assertEqual(response.status_code, 404)

View File

View File

@@ -0,0 +1,88 @@
from django.test import TestCase
from apps.drama.models import GameEvent, record
from apps.epic.models import Room
from apps.lyric.models import User
BASE = "https://earthmanrpg.me"
class ToActivityTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="actor@test.io", username="testactor")
self.room = Room.objects.create(name="Test Room", owner=self.user)
def _record(self, verb, **data):
return record(self.room, verb, actor=self.user, **data)
def test_slot_filled_returns_join_gate_activity(self):
event = self._record(
GameEvent.SLOT_FILLED,
slot_number=1, token_type="coin",
token_display="Coin", renewal_days=7,
)
activity = event.to_activity(BASE)
self.assertIsNotNone(activity)
self.assertEqual(activity["type"], "earthman:JoinGate")
def test_role_selected_returns_select_role_activity(self):
event = self._record(
GameEvent.ROLE_SELECTED,
role="PC", slot_number=1, role_display="Player",
)
activity = event.to_activity(BASE)
self.assertIsNotNone(activity)
self.assertEqual(activity["type"], "earthman:SelectRole")
def test_room_created_returns_create_activity(self):
event = self._record(GameEvent.ROOM_CREATED)
activity = event.to_activity(BASE)
self.assertIsNotNone(activity)
self.assertEqual(activity["type"], "Create")
def test_unsupported_verb_returns_none(self):
event = self._record(GameEvent.INVITE_SENT)
self.assertIsNone(event.to_activity(BASE))
def test_activity_contains_actor_url(self):
event = self._record(
GameEvent.ROLE_SELECTED,
role="PC", slot_number=1, role_display="Player",
)
activity = event.to_activity(BASE)
self.assertIn(BASE, activity["actor"])
def test_activity_contains_object_url(self):
event = self._record(
GameEvent.SLOT_FILLED,
slot_number=1, token_type="coin",
token_display="Coin", renewal_days=7,
)
activity = event.to_activity(BASE)
self.assertIn(str(self.room.id), activity["object"])
class EnsureKeypairTest(TestCase):
def test_ensure_keypair_populates_both_fields(self):
user = User.objects.create(email="keys@test.io")
self.assertEqual(user.ap_public_key, "")
self.assertEqual(user.ap_private_key, "")
user.ensure_keypair()
self.assertTrue(user.ap_public_key.startswith("-----BEGIN PUBLIC KEY-----"))
self.assertTrue(user.ap_private_key.startswith("-----BEGIN PRIVATE KEY-----"))
def test_ensure_keypair_persists_to_db(self):
user = User.objects.create(email="persist@test.io")
user.ensure_keypair()
refreshed = User.objects.get(pk=user.pk)
self.assertTrue(refreshed.ap_public_key.startswith("-----BEGIN PUBLIC KEY-----"))
def test_ensure_keypair_is_idempotent(self):
user = User.objects.create(email="idem@test.io")
user.ensure_keypair()
original_pub = user.ap_public_key
user.ensure_keypair()
self.assertEqual(user.ap_public_key, original_pub)

10
src/apps/ap/urls.py Normal file
View File

@@ -0,0 +1,10 @@
from django.urls import path
from . import views
app_name = "ap"
urlpatterns = [
path("users/<str:username>/", views.actor, name="actor"),
path("users/<str:username>/outbox/", views.outbox, name="outbox"),
]

83
src/apps/ap/views.py Normal file
View File

@@ -0,0 +1,83 @@
import json
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404
from apps.lyric.models import User
AP_CONTEXT = [
"https://www.w3.org/ns/activitystreams",
{"earthman": "https://earthmanrpg.me/ns#"},
]
def _base_url(request):
return f"{request.scheme}://{request.get_host()}"
def _ap_response(data):
return HttpResponse(
json.dumps(data),
content_type="application/activity+json",
)
def webfinger(request):
resource = request.GET.get("resource", "")
if not resource:
return HttpResponse(status=400)
# Expect acct:username@host
if not resource.startswith("acct:"):
return HttpResponse(status=400)
username = resource[len("acct:"):].split("@")[0]
user = get_object_or_404(User, username=username)
base = _base_url(request)
data = {
"subject": resource,
"links": [
{
"rel": "self",
"type": "application/activity+json",
"href": f"{base}/ap/users/{user.username}/",
}
],
}
return HttpResponse(json.dumps(data), content_type="application/jrd+json")
def actor(request, username):
user = get_object_or_404(User, username=username)
user.ensure_keypair()
base = _base_url(request)
actor_url = f"{base}/ap/users/{username}/"
data = {
"@context": AP_CONTEXT,
"id": actor_url,
"type": "Person",
"preferredUsername": username,
"inbox": f"{actor_url}inbox/",
"outbox": f"{actor_url}outbox/",
"publicKey": {
"id": f"{actor_url}#main-key",
"owner": actor_url,
"publicKeyPem": user.ap_public_key,
},
}
return _ap_response(data)
def outbox(request, username):
user = get_object_or_404(User, username=username)
base = _base_url(request)
events = user.game_events.select_related("room").order_by("timestamp")
activities = [a for e in events if (a := e.to_activity(base)) is not None]
actor_url = f"{base}/ap/users/{username}/"
data = {
"@context": AP_CONTEXT,
"id": f"{actor_url}outbox/",
"type": "OrderedCollection",
"totalItems": len(activities),
"orderedItems": activities,
}
return _ap_response(data)

View File

@@ -1,21 +1,29 @@
from rest_framework import serializers
from apps.dashboard.models import Item, List
from apps.dashboard.models import Item, Note
from apps.lyric.models import User
class ItemSerializer(serializers.ModelSerializer):
text = serializers.CharField()
def validate_text(self, value):
note = self.context["note"]
if note.item_set.filter(text=value).exists():
raise serializers.ValidationError("duplicate")
return value
class Meta:
model = Item
fields = ["id", "text"]
class ListSerializer(serializers.ModelSerializer):
class NoteSerializer(serializers.ModelSerializer):
name = serializers.ReadOnlyField()
url = serializers.CharField(source="get_absolute_url", read_only=True)
items = ItemSerializer(many=True, read_only=True, source="item_set")
class Meta:
model = List
model = Note
fields = ["id", "name", "url", "items"]
class UserSerializer(serializers.ModelSerializer):

View File

@@ -1,7 +1,7 @@
from django.test import TestCase
from rest_framework.test import APIClient
from apps.dashboard.models import Item, List
from apps.dashboard.models import Item, Note
from apps.lyric.models import User
class BaseAPITest(TestCase):
@@ -11,25 +11,24 @@ class BaseAPITest(TestCase):
self.user = User.objects.create_user("test@example.com")
self.client.force_authenticate(user=self.user)
class ListDetailAPITest(BaseAPITest):
def test_returns_list_with_items(self):
list_ = List.objects.create(owner=self.user)
Item.objects.create(text="item 1", list=list_)
Item.objects.create(text="item 2", list=list_)
class NoteDetailAPITest(BaseAPITest):
def test_returns_note_with_items(self):
note = Note.objects.create(owner=self.user)
Item.objects.create(text="item 1", note=note)
Item.objects.create(text="item 2", note=note)
response = self.client.get(f"/api/lists/{list_.id}/")
response = self.client.get(f"/api/notes/{note.id}/")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data["id"], str(list_.id))
self.assertEqual(response.data["id"], str(note.id))
self.assertEqual(len(response.data["items"]), 2)
class ListItemsAPITest(BaseAPITest):
def test_can_add_item_to_list(self):
list_ = List.objects.create(owner=self.user)
class NoteItemsAPITest(BaseAPITest):
def test_can_add_item_to_note(self):
note = Note.objects.create(owner=self.user)
response = self.client.post(
f"/api/lists/{list_.id}/items/",
f"/api/notes/{note.id}/items/",
{"text": "a new item"},
)
@@ -37,28 +36,50 @@ class ListItemsAPITest(BaseAPITest):
self.assertEqual(Item.objects.count(), 1)
self.assertEqual(Item.objects.first().text, "a new item")
class ListsAPITest(BaseAPITest):
def test_get_returns_only_users_lists(self):
list1 = List.objects.create(owner=self.user)
Item.objects.create(text="item 1", list=list1)
other_user = User.objects.create_user("other@example.com")
List.objects.create(owner=other_user)
def test_cannot_add_empty_item_to_note(self):
note = Note.objects.create(owner=self.user)
response = self.client.get("/api/lists/")
response = self.client.post(
f"/api/notes/{note.id}/items/",
{"text": ""},
)
self.assertEqual(response.status_code, 400)
self.assertEqual(Item.objects.count(), 0)
def test_cannot_add_duplicate_item_to_note(self):
note = Note.objects.create(owner=self.user)
Item.objects.create(text="note item", note=note)
duplicate_response = self.client.post(
f"/api/notes/{note.id}/items/",
{"text": "note item"},
)
self.assertEqual(duplicate_response.status_code, 400)
self.assertEqual(Item.objects.count(), 1)
class NotesAPITest(BaseAPITest):
def test_get_returns_only_users_notes(self):
note1 = Note.objects.create(owner=self.user)
Item.objects.create(text="item 1", note=note1)
other_user = User.objects.create_user("other@example.com")
Note.objects.create(owner=other_user)
response = self.client.get("/api/notes/")
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0]["id"], str(list1.id))
self.assertEqual(response.data[0]["id"], str(note1.id))
def test_post_creates_list_with_item(self):
def test_post_creates_note_with_item(self):
response = self.client.post(
"/api/lists/",
"/api/notes/",
{"text": "first item"},
)
self.assertEqual(response.status_code, 201)
self.assertEqual(List.objects.count(), 1)
self.assertEqual(List.objects.first().owner, self.user)
self.assertEqual(Note.objects.count(), 1)
self.assertEqual(Note.objects.first().owner, self.user)
self.assertEqual(Item.objects.first().text, "first item")
class UserSearchAPITest(BaseAPITest):

View File

@@ -1,5 +1,5 @@
from django.test import SimpleTestCase
from apps.api.serializers import ItemSerializer, ListSerializer
from apps.api.serializers import ItemSerializer, NoteSerializer
class ItemSerializerTest(SimpleTestCase):
@@ -10,11 +10,10 @@ class ItemSerializerTest(SimpleTestCase):
{"id", "text"},
)
class ListSerializerTest(SimpleTestCase):
class NoteSerializerTest(SimpleTestCase):
def test_fields(self):
serializer = ListSerializer()
serializer = NoteSerializer()
self.assertEqual(
set(serializer.fields.keys()),
{"id", "name", "url", "items"},
)

View File

@@ -4,9 +4,8 @@ from . import views
urlpatterns = [
path('lists/', views.ListsAPI.as_view(), name='api_lists'),
path('lists/<uuid:list_id>/', views.ListDetailAPI.as_view(), name='api_list_detail'),
path('lists/<uuid:list_id>/items/', views.ListItemsAPI.as_view(), name='api_list_items'),
path('notes/', views.NotesAPI.as_view(), name='api_notes'),
path('notes/<uuid:note_id>/', views.NoteDetailAPI.as_view(), name='api_note_detail'),
path('notes/<uuid:note_id>/items/', views.NoteItemsAPI.as_view(), name='api_note_items'),
path('users/', views.UserSearchAPI.as_view(), name='api_users'),
]

View File

@@ -2,36 +2,36 @@ from django.shortcuts import get_object_or_404
from rest_framework.views import APIView
from rest_framework.response import Response
from apps.api.serializers import ItemSerializer, ListSerializer, UserSerializer
from apps.dashboard.models import Item, List
from apps.api.serializers import ItemSerializer, NoteSerializer, UserSerializer
from apps.dashboard.models import Item, Note
from apps.lyric.models import User
class ListDetailAPI(APIView):
def get(self, request, list_id):
list_ = get_object_or_404(List, id=list_id)
serializer = ListSerializer(list_)
class NoteDetailAPI(APIView):
def get(self, request, note_id):
note = get_object_or_404(Note, id=note_id)
serializer = NoteSerializer(note)
return Response(serializer.data)
class ListItemsAPI(APIView):
def post(self, request, list_id):
list_ = get_object_or_404(List, id=list_id)
serializer = ItemSerializer(data=request.data)
class NoteItemsAPI(APIView):
def post(self, request, note_id):
note = get_object_or_404(Note, id=note_id)
serializer = ItemSerializer(data=request.data, context={"note": note})
if serializer.is_valid():
serializer.save(list=list_)
serializer.save(note=note)
return Response(serializer.data, status=201)
return Response(serializer.errors, status=400)
class ListsAPI(APIView):
class NotesAPI(APIView):
def get(self, request):
lists = List.objects.filter(owner=request.user)
serializer = ListSerializer(lists, many=True)
notes = Note.objects.filter(owner=request.user)
serializer = NoteSerializer(notes, many=True)
return Response(serializer.data)
def post(self, request):
list_ = List.objects.create(owner=request.user)
item = Item.objects.create(text=request.data.get("text", ""), list=list_)
serializer = ListSerializer(list_)
note = Note.objects.create(owner=request.user)
item = Item.objects.create(text=request.data.get("text", ""), note=note)
serializer = NoteSerializer(note)
return Response(serializer.data, status=201)
class UserSearchAPI(APIView):

View File

11
src/apps/applets/admin.py Normal file
View File

@@ -0,0 +1,11 @@
from django.contrib import admin
from apps.applets.models import Applet, UserApplet
@admin.register(Applet)
class AppletAdmin(admin.ModelAdmin):
list_display = ['slug', 'name', 'default_visible', 'grid_cols', 'grid_rows']
list_editable = ['grid_cols', 'grid_rows']
admin.site.register(UserApplet)

5
src/apps/applets/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class AppletsConfig(AppConfig):
name = 'apps.applets'

View File

@@ -0,0 +1,36 @@
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Applet',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(unique=True)),
('name', models.CharField(max_length=100)),
('context', models.CharField(choices=[('dashboard', 'Dashboard'), ('gameboard', 'Gameboard')], default='dashboard', max_length=20)),
('default_visible', models.BooleanField(default=True)),
('grid_cols', models.PositiveSmallIntegerField(default=12)),
('grid_rows', models.PositiveSmallIntegerField(default=3)),
],
),
migrations.CreateModel(
name='UserApplet',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('visible', models.BooleanField(default=True)),
('applet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='applets.applet')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_applets', to=settings.AUTH_USER_MODEL)),
],
options={'unique_together': {('user', 'applet')}},
),
]

View File

@@ -0,0 +1,29 @@
from django.db import migrations
def seed_applets(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
for slug, name, cols, rows, context in [
('wallet', 'Wallet', 12, 3, 'dashboard'),
('new-list', 'New List', 9, 3, 'dashboard'),
('my-lists', 'My Lists', 3, 3, 'dashboard'),
('username', 'Username', 6, 3, 'dashboard'),
('palette', 'Palette', 6, 3, 'dashboard'),
('new-game', 'New Game', 4, 2, 'gameboard'),
('my-games', 'My Games', 4, 4, 'gameboard'),
('game-kit', 'Game Kit', 4, 2, 'gameboard'),
]:
Applet.objects.get_or_create(
slug=slug,
defaults={'name': name, 'grid_cols': cols, 'grid_rows': rows, 'context': context},
)
class Migration(migrations.Migration):
dependencies = [
('applets', '0001_initial')
]
operations = [
migrations.RunPython(seed_applets, migrations.RunPython.noop)
]

View File

@@ -0,0 +1,37 @@
from django.db import migrations, models
def seed_wallet_applets(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
for slug, name, cols, rows in [
('wallet-balances', 'Wallet Balances', 3, 3),
('wallet-tokens', 'Wallet Tokens', 3, 3),
('wallet-payment', 'Payment Methods', 6, 2),
]:
Applet.objects.get_or_create(
slug=slug,
defaults={'name': name, 'grid_cols': cols, 'grid_rows': rows, 'context': 'wallet'},
)
class Migration(migrations.Migration):
dependencies = [
('applets', '0002_seed_applets'),
]
operations = [
migrations.AlterField(
model_name='applet',
name='context',
field=models.CharField(
choices=[
('dashboard', 'Dashboard'),
('gameboard', 'Gameboard'),
('wallet', 'Wallet'),
],
default='dashboard',
max_length=20,
),
),
migrations.RunPython(seed_wallet_applets, migrations.RunPython.noop),
]

View File

@@ -0,0 +1,24 @@
from django.db import migrations
def rename_list_slugs(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
Applet.objects.filter(slug='new-list').update(slug='new-note', name='New Note')
Applet.objects.filter(slug='my-lists').update(slug='my-notes', name='My Notes')
def reverse_rename_list_slugs(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
Applet.objects.filter(slug='new-note').update(slug='new-list', name='New List')
Applet.objects.filter(slug='my-notes').update(slug='my-lists', name='My Lists')
class Migration(migrations.Migration):
dependencies = [
('applets', '0003_wallet_applets'),
]
operations = [
migrations.RunPython(rename_list_slugs, reverse_rename_list_slugs),
]

View File

@@ -0,0 +1,24 @@
from django.db import migrations
def increase_gameboard_applet_heights(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
Applet.objects.filter(slug__in=['new-game', 'game-kit', 'wallet-payment']).update(grid_rows=3)
def revert_gameboard_applet_heights(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
Applet.objects.filter(slug__in=['new-game', 'game-kit', 'wallet-payment']).update(grid_rows=2)
class Migration(migrations.Migration):
dependencies = [
('applets', '0004_rename_list_applet_slugs')
]
operations = [
migrations.RunPython(
increase_gameboard_applet_heights,
revert_gameboard_applet_heights,
)
]

View File

@@ -0,0 +1,48 @@
from django.db import migrations, models
def seed_billboard_applets(apps, schema_editor):
Applet = apps.get_model("applets", "Applet")
for slug, name, cols, rows in [
("billboard-my-scrolls", "My Scrolls", 4, 3),
("billboard-my-contacts", "Contacts", 4, 3),
("billboard-most-recent", "Most Recent", 8, 6),
]:
Applet.objects.get_or_create(
slug=slug,
defaults={"name": name, "grid_cols": cols, "grid_rows": rows, "context": "billboard"},
)
def remove_billboard_applets(apps, schema_editor):
Applet = apps.get_model("applets", "Applet")
Applet.objects.filter(slug__in=[
"billboard-my-scrolls",
"billboard-my-contacts",
"billboard-most-recent",
]).delete()
class Migration(migrations.Migration):
dependencies = [
("applets", "0005_gameboard_applet_heights"),
]
operations = [
migrations.AlterField(
model_name="applet",
name="context",
field=models.CharField(
choices=[
("dashboard", "Dashboard"),
("gameboard", "Gameboard"),
("wallet", "Wallet"),
("billboard", "Billboard"),
],
default="dashboard",
max_length=20,
),
),
migrations.RunPython(seed_billboard_applets, remove_billboard_applets),
]

View File

@@ -0,0 +1,29 @@
from django.db import migrations
def fix_billboard_applets(apps, schema_editor):
Applet = apps.get_model("applets", "Applet")
# billboard-scroll belongs only to the billscroll page template, not the grid
Applet.objects.filter(slug="billboard-scroll").delete()
# Rename "My Contacts" → "Contacts"
Applet.objects.filter(slug="billboard-my-contacts").update(name="Contacts")
def reverse_fix_billboard_applets(apps, schema_editor):
Applet = apps.get_model("applets", "Applet")
Applet.objects.get_or_create(
slug="billboard-scroll",
defaults={"name": "Billscroll", "grid_cols": 12, "grid_rows": 6, "context": "billboard"},
)
Applet.objects.filter(slug="billboard-my-contacts").update(name="My Contacts")
class Migration(migrations.Migration):
dependencies = [
("applets", "0006_billboard_applets"),
]
operations = [
migrations.RunPython(fix_billboard_applets, reverse_fix_billboard_applets),
]

View File

@@ -0,0 +1,25 @@
from django.db import migrations
def seed_game_kit_applets(apps, schema_editor):
Applet = apps.get_model('applets', 'Applet')
for slug, name in [
('gk-trinkets', 'Trinkets'),
('gk-tokens', 'Tokens'),
('gk-decks', 'Card Decks'),
('gk-dice', 'Dice Sets'),
]:
Applet.objects.get_or_create(
slug=slug,
defaults={'name': name, 'grid_cols': 3, 'grid_rows': 3, 'context': 'game-kit'},
)
class Migration(migrations.Migration):
dependencies = [
('applets', '0007_fix_billboard_applets'),
]
operations = [
migrations.RunPython(seed_game_kit_applets, migrations.RunPython.noop)
]

View File

View File

@@ -0,0 +1,38 @@
from django.db import models
class Applet(models.Model):
DASHBOARD = "dashboard"
GAMEBOARD = "gameboard"
WALLET = "wallet"
BILLBOARD = "billboard"
CONTEXT_CHOICES = [
(DASHBOARD, "Dashboard"),
(GAMEBOARD, "Gameboard"),
(WALLET, "Wallet"),
(BILLBOARD, "Billboard"),
]
slug = models.SlugField(unique=True)
name = models.CharField(max_length=100)
context = models.CharField(max_length=20, choices=CONTEXT_CHOICES, default=DASHBOARD)
default_visible = models.BooleanField(default=True)
grid_cols = models.PositiveSmallIntegerField(default=12)
grid_rows = models.PositiveSmallIntegerField(default=3)
def __str__(self):
return self.name
class UserApplet(models.Model):
user = models.ForeignKey(
"lyric.User",
related_name="user_applets",
on_delete=models.CASCADE,
)
applet = models.ForeignKey(
Applet,
on_delete=models.CASCADE,
)
visible = models.BooleanField(default=True)
class Meta:
unique_together = ("user", "applet")

View File

@@ -0,0 +1,42 @@
const initGearMenus = () => {
document.querySelectorAll('.gear-btn').forEach(gear => {
const menuId = gear.dataset.menuTarget;
gear.addEventListener('click', (e) => {
e.stopPropagation();
const menu = document.getElementById(menuId);
if (!menu) return;
const opening = menu.style.display === 'none' || menu.style.display === '';
menu.style.display = opening ? 'block' : 'none';
gear.classList.toggle('active', opening);
});
document.addEventListener('click', (e) => {
const menu = document.getElementById(menuId);
if (!menu || menu.style.display === 'none') return;
if (e.target.closest('.applet-menu-cancel') || !menu.contains(e.target)) {
menu.style.display = 'none';
gear.classList.remove('active');
}
});
})
};
document.addEventListener('DOMContentLoaded', initGearMenus);
const appletContainerIds = new Set([
'id_applets_container',
'id_game_applets_container',
'id_gk_sections_container',
'id_wallet_applets_container',
]);
document.body.addEventListener('htmx:afterSwap', (e) => {
if (!e.detail.target || !appletContainerIds.has(e.detail.target.id)) return;
document.querySelectorAll('.gear-btn').forEach(gear => {
const menu = document.getElementById(gear.dataset.menuTarget);
if (menu) menu.style.display = 'none';
gear.classList.remove('active');
});
});

View File

View File

@@ -0,0 +1,65 @@
from django.db.utils import IntegrityError
from django.test import TestCase
from apps.applets.models import Applet, UserApplet
from apps.applets.utils import applet_context
from apps.lyric.models import User
class AppletModelTest(TestCase):
def setUp(self):
self.applet = Applet.objects.create(
slug="my-applet", name="My Applet", default_visible=True
)
def test_applet_can_be_created(self):
self.assertEqual(Applet.objects.get(slug="my-applet"), self.applet)
def test_applet_slug_is_unique(self):
with self.assertRaises(IntegrityError):
Applet.objects.create(slug="my-applet", name="Second")
def test_applet_str(self):
self.assertEqual(str(self.applet), "My Applet")
def test_applet_grid_defaults(self):
self.assertEqual(self.applet.grid_cols, 12)
self.assertEqual(self.applet.grid_rows, 3)
class UserAppletModelTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="a@b.cde")
self.applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username"})
def test_user_applet_links_user_to_applet(self):
ua = UserApplet.objects.create(user=self.user, applet=self.applet, visible=True)
self.assertIn(ua, self.user.user_applets.all())
def test_user_applet_unique_per_user_and_applet(self):
UserApplet.objects.create(user=self.user, applet=self.applet, visible=True)
with self.assertRaises(IntegrityError):
UserApplet.objects.create(user=self.user, applet=self.applet, visible=False)
class AppletContextTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="a@b.cde")
self.dash_applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username", "context": "dashboard"})
self.game_applet, _ = Applet.objects.get_or_create(slug="new-game", defaults={"name": "New Game", "context": "gameboard"})
def test_filters_by_context(self):
result = applet_context(self.user, "dashboard")
slugs = [e["applet"].slug for e in result]
self.assertIn("username", slugs)
self.assertNotIn("new-game", slugs)
def test_defaults_to_applet_default_visible(self):
result = applet_context(self.user, "dashboard")
[entry] = [e for e in result if e["applet"].slug == "username"]
self.assertTrue(entry["visible"])
def test_respects_user_applet_visible_false(self):
UserApplet.objects.create(user=self.user, applet=self.dash_applet, visible=False)
result = applet_context(self.user, "dashboard")
[entry] = [e for e in result if e["applet"].slug == "username"]
self.assertFalse(entry["visible"])

11
src/apps/applets/utils.py Normal file
View File

@@ -0,0 +1,11 @@
from apps.applets.models import Applet, UserApplet
def applet_context(user, context):
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
applets = {a.slug: a for a in Applet.objects.filter(context=context)}
return [
{"applet": applets[slug], "visible": ua_map.get(applets[slug].pk, applets[slug].default_visible)}
for slug in applets
if slug in applets
]

View File

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class BillboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.billboard'

View File

View File

@@ -0,0 +1,189 @@
from django.test import TestCase
from django.urls import reverse
from apps.applets.models import Applet
from apps.drama.models import GameEvent, ScrollPosition, record
from apps.epic.models import Room
from apps.lyric.models import User
def _seed_billboard_applets():
for slug, name, cols, rows in [
("billboard-my-scrolls", "My Scrolls", 4, 3),
("billboard-my-contacts", "Contacts", 4, 3),
("billboard-most-recent", "Most Recent", 8, 6),
]:
Applet.objects.get_or_create(
slug=slug,
defaults={"name": name, "grid_cols": cols, "grid_rows": rows, "context": "billboard"},
)
class BillboardViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="test@billboard.io")
self.client.force_login(self.user)
_seed_billboard_applets()
def test_uses_billboard_template(self):
response = self.client.get("/billboard/")
self.assertTemplateUsed(response, "apps/billboard/billboard.html")
def test_passes_applets_context(self):
response = self.client.get("/billboard/")
self.assertIn("applets", response.context)
slugs = [e["applet"].slug for e in response.context["applets"]]
self.assertIn("billboard-my-scrolls", slugs)
self.assertIn("billboard-my-contacts", slugs)
self.assertIn("billboard-most-recent", slugs)
def test_passes_my_rooms_context(self):
room = Room.objects.create(name="Test Room", owner=self.user)
response = self.client.get("/billboard/")
self.assertIn(room, response.context["my_rooms"])
def test_passes_recent_room_and_events(self):
room = Room.objects.create(name="Test Room", owner=self.user)
record(
room, GameEvent.SLOT_FILLED, actor=self.user,
slot_number=1, token_type="coin",
token_display="Coin-on-a-String", renewal_days=7,
)
response = self.client.get("/billboard/")
self.assertEqual(response.context["recent_room"], room)
self.assertEqual(len(response.context["recent_events"]), 1)
def test_recent_events_capped_at_36(self):
room = Room.objects.create(name="Test Room", owner=self.user)
for i in range(40):
record(
room, GameEvent.SLOT_FILLED, actor=self.user,
slot_number=1, token_type="coin",
token_display="Coin-on-a-String", renewal_days=7,
)
response = self.client.get("/billboard/")
self.assertEqual(len(response.context["recent_events"]), 36)
def test_recent_events_in_chronological_order(self):
room = Room.objects.create(name="Test Room", owner=self.user)
for _ in range(3):
record(
room, GameEvent.SLOT_FILLED, actor=self.user,
slot_number=1, token_type="coin",
token_display="Coin-on-a-String", renewal_days=7,
)
response = self.client.get("/billboard/")
events = response.context["recent_events"]
timestamps = [e.timestamp for e in events]
self.assertEqual(timestamps, sorted(timestamps))
def test_recent_room_is_none_when_no_events(self):
response = self.client.get("/billboard/")
self.assertIsNone(response.context["recent_room"])
self.assertEqual(list(response.context["recent_events"]), [])
class ToggleBillboardAppletsTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="test@toggle.io")
self.client.force_login(self.user)
_seed_billboard_applets()
def test_toggle_hides_unchecked_applets(self):
response = self.client.post(
reverse("billboard:toggle_applets"),
{"applets": ["billboard-my-scrolls"]},
)
self.assertEqual(response.status_code, 302)
from apps.applets.models import UserApplet
contacts = Applet.objects.get(slug="billboard-my-contacts")
ua = UserApplet.objects.get(user=self.user, applet=contacts)
self.assertFalse(ua.visible)
def test_toggle_returns_partial_on_htmx(self):
response = self.client.post(
reverse("billboard:toggle_applets"),
{"applets": ["billboard-my-scrolls"]},
HTTP_HX_REQUEST="true",
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "apps/billboard/_partials/_applets.html")
class BillscrollViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="test@billscroll.io")
self.client.force_login(self.user)
self.room = Room.objects.create(name="Test Room", owner=self.user)
record(
self.room, GameEvent.SLOT_FILLED, actor=self.user,
slot_number=1, token_type="coin",
token_display="Coin-on-a-String", renewal_days=7,
)
def test_uses_room_scroll_template(self):
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertTemplateUsed(response, "apps/billboard/room_scroll.html")
def test_passes_events_context(self):
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertIn("events", response.context)
self.assertEqual(response.context["events"].count(), 1)
def test_passes_page_class_billscroll(self):
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertEqual(response.context["page_class"], "page-billscroll")
def test_passes_scroll_position_zero_when_none_saved(self):
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertEqual(response.context["scroll_position"], 0)
def test_passes_saved_scroll_position_in_context(self):
ScrollPosition.objects.create(user=self.user, room=self.room, position=250)
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertEqual(response.context["scroll_position"], 250)
def test_scroll_renders_event_body_and_time_columns(self):
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
self.assertContains(response, 'class="drama-event-body"')
self.assertContains(response, 'class="drama-event-time"')
class SaveScrollPositionTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="test@savescroll.io")
self.client.force_login(self.user)
self.room = Room.objects.create(name="Test Room", owner=self.user)
def test_post_saves_scroll_position(self):
self.client.post(
f"/billboard/room/{self.room.id}/scroll-position/",
{"position": 300},
)
sp = ScrollPosition.objects.get(user=self.user, room=self.room)
self.assertEqual(sp.position, 300)
def test_post_updates_existing_position(self):
ScrollPosition.objects.create(user=self.user, room=self.room, position=100)
self.client.post(
f"/billboard/room/{self.room.id}/scroll-position/",
{"position": 450},
)
self.assertEqual(
ScrollPosition.objects.get(user=self.user, room=self.room).position, 450
)
def test_post_returns_204(self):
response = self.client.post(
f"/billboard/room/{self.room.id}/scroll-position/",
{"position": 100},
)
self.assertEqual(response.status_code, 204)
def test_post_requires_login(self):
self.client.logout()
response = self.client.post(
f"/billboard/room/{self.room.id}/scroll-position/",
{"position": 100},
)
self.assertEqual(response.status_code, 302)

View File

@@ -0,0 +1,12 @@
from django.urls import path
from apps.billboard import views
app_name = "billboard"
urlpatterns = [
path("", views.billboard, name="billboard"),
path("toggle-applets", views.toggle_billboard_applets, name="toggle_applets"),
path("room/<uuid:room_id>/scroll/", views.room_scroll, name="scroll"),
path("room/<uuid:room_id>/scroll-position/", views.save_scroll_position, name="save_scroll_position"),
]

View File

@@ -0,0 +1,86 @@
from django.contrib.auth.decorators import login_required
from django.db.models import Max, Q
from django.shortcuts import redirect, render
from apps.applets.models import Applet, UserApplet
from apps.applets.utils import applet_context
from apps.drama.models import GameEvent, ScrollPosition
from apps.epic.models import GateSlot, Room, RoomInvite
@login_required(login_url="/")
def billboard(request):
my_rooms = Room.objects.filter(
Q(owner=request.user) |
Q(gate_slots__gamer=request.user) |
Q(invites__invitee_email=request.user.email, invites__status=RoomInvite.PENDING)
).distinct().order_by("-created_at")
recent_room = (
Room.objects.filter(
Q(owner=request.user) | Q(gate_slots__gamer=request.user)
)
.annotate(last_event=Max("events__timestamp"))
.filter(last_event__isnull=False)
.order_by("-last_event")
.distinct()
.first()
)
recent_events = (
list(recent_room.events.select_related("actor").order_by("-timestamp")[:36])[::-1]
if recent_room else []
)
return render(request, "apps/billboard/billboard.html", {
"my_rooms": my_rooms,
"recent_room": recent_room,
"recent_events": recent_events,
"viewer": request.user,
"applets": applet_context(request.user, "billboard"),
"page_class": "page-billboard",
})
@login_required(login_url="/")
def toggle_billboard_applets(request):
checked = request.POST.getlist("applets")
for applet in Applet.objects.filter(context="billboard"):
UserApplet.objects.update_or_create(
user=request.user,
applet=applet,
defaults={"visible": applet.slug in checked},
)
if request.headers.get("HX-Request"):
return render(request, "apps/billboard/_partials/_applets.html", {
"applets": applet_context(request.user, "billboard"),
})
return redirect("billboard:billboard")
@login_required(login_url="/")
def room_scroll(request, room_id):
room = Room.objects.get(id=room_id)
events = room.events.select_related("actor").all()
sp = ScrollPosition.objects.filter(user=request.user, room=room).first()
return render(request, "apps/billboard/room_scroll.html", {
"room": room,
"events": events,
"viewer": request.user,
"scroll_position": sp.position if sp else 0,
"page_class": "page-billscroll",
})
@login_required(login_url="/")
def save_scroll_position(request, room_id):
if request.method != "POST":
from django.http import HttpResponseNotAllowed
return HttpResponseNotAllowed(["POST"])
room = Room.objects.get(id=room_id)
position = int(request.POST.get("position", 0))
ScrollPosition.objects.update_or_create(
user=request.user, room=room,
defaults={"position": position},
)
from django.http import HttpResponse
return HttpResponse(status=204)

View File

@@ -1,3 +1 @@
from django.contrib import admin
# Register your models here.

View File

@@ -2,8 +2,8 @@ from django import forms
from django.core.exceptions import ValidationError
from .models import Item
DUPLICATE_ITEM_ERROR = "You've already logged this to your list"
EMPTY_ITEM_ERROR = "You can't have an empty list item"
DUPLICATE_ITEM_ERROR = "You've already logged this to your note"
EMPTY_ITEM_ERROR = "You can't have an empty note item"
class ItemForm(forms.Form):
text = forms.CharField(
@@ -11,22 +11,22 @@ class ItemForm(forms.Form):
required=True,
)
def save(self, for_list):
def save(self, for_note):
return Item.objects.create(
list=for_list,
note=for_note,
text=self.cleaned_data["text"],
)
class ExistingListItemForm(ItemForm):
def __init__(self, for_list, *args, **kwargs):
class ExistingNoteItemForm(ItemForm):
def __init__(self, for_note, *args, **kwargs):
super().__init__(*args, **kwargs)
self._for_list = for_list
self._for_note = for_note
def clean_text(self):
text = self.cleaned_data["text"]
if self._for_list.item_set.filter(text=text).exists():
if self._for_note.item_set.filter(text=text).exists():
raise forms.ValidationError(DUPLICATE_ITEM_ERROR)
return text
def save(self):
return super().save(for_list=self._for_list)
return super().save(for_note=self._for_note)

View File

@@ -0,0 +1,20 @@
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='List',
new_name='Note',
),
migrations.RenameField(
model_name='Item',
old_name='list',
new_name='note',
),
]

View File

@@ -0,0 +1,26 @@
# Generated by Django 6.0 on 2026-03-12 19:30
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0002_rename_list_to_note'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name='note',
name='owner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='note',
name='shared_with',
field=models.ManyToManyField(blank=True, related_name='shared_notes', to=settings.AUTH_USER_MODEL),
),
]

View File

@@ -4,11 +4,11 @@ from django.db import models
from django.urls import reverse
class List(models.Model):
class Note(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
owner = models.ForeignKey(
"lyric.User",
related_name="lists",
related_name="notes",
blank=True,
null=True,
on_delete=models.CASCADE,
@@ -16,7 +16,7 @@ class List(models.Model):
shared_with = models.ManyToManyField(
"lyric.User",
related_name="shared_lists",
related_name="shared_notes",
blank=True,
)
@@ -25,16 +25,15 @@ class List(models.Model):
return self.item_set.first().text
def get_absolute_url(self):
return reverse("view_list", args=[self.id])
return reverse("view_note", args=[self.id])
class Item(models.Model):
text = models.TextField(default="")
list = models.ForeignKey(List, default=None, on_delete=models.CASCADE)
note = models.ForeignKey(Note, default=None, on_delete=models.CASCADE)
class Meta:
ordering = ("id",)
unique_together = ("list", "text")
unique_together = ("note", "text")
def __str__(self):
return self.text

View File

@@ -0,0 +1,43 @@
// console.log("apps/scripts/dashboard.js loading");
const initialize = (inputSelector) => {
// console.log("initialize called!");
const textInput = document.querySelector(inputSelector);
if (!textInput) return;
textInput.oninput = () => {
// console.log("oninput triggered");
textInput.classList.remove("is-invalid");
};
};
const bindPaletteWheel = () => {
document.querySelectorAll('.palette-scroll').forEach(el => {
el.addEventListener('wheel', (e) => {
e.preventDefault();
el.scrollLeft += e.deltaY;
}, { passive: false });
});
};
const bindPaletteForms = () => {
document.querySelectorAll('form[action*="set_palette"]').forEach(form => {
form.addEventListener("submit", async (e) => {
e.preventDefault();
const resp = await fetch(form.action, {
method: "POST",
headers: { "Accept": "application/json" },
body: new FormData(form, e.submitter),
});
if (!resp.ok) return;
const { palette } = await resp.json();
// Swap body palette class
[...document.body.classList]
.filter(c => c.startsWith("palette-"))
.forEach(c => document.body.classList.remove(c));
document.body.classList.add(palette);
// Update active swatch indicator
document.querySelectorAll(".swatch").forEach(sw => {
sw.classList.toggle("active", sw.classList.contains(palette));
});
});
});
};

View File

@@ -0,0 +1,95 @@
(function () {
var btn = document.getElementById('id_kit_btn');
var dialog = document.getElementById('id_kit_bag_dialog');
if (!btn || !dialog) return;
btn.addEventListener('click', function () {
if (dialog.hasAttribute('open')) {
dialog.removeAttribute('open');
btn.classList.remove('active');
return;
}
fetch(btn.dataset.kitUrl, {
headers: { 'X-Requested-With': 'XMLHttpRequest' },
})
.then(function (r) { return r.text(); })
.then(function (html) {
dialog.innerHTML = html;
attachCardListeners();
btn.classList.add('active');
dialog.setAttribute('open', '');
})
.catch(function () {
btn.classList.remove('active');
});
});
// Escape key
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && dialog.hasAttribute('open')) {
dialog.removeAttribute('open');
btn.classList.remove('active');
}
});
// Click outside (but not on the rails button — let that flow through)
document.addEventListener('click', function (e) {
if (!dialog.hasAttribute('open')) return;
if (dialog.contains(e.target)) return;
if (e.target === btn || btn.contains(e.target)) return;
if (e.target.closest('button.token-rails')) return;
dialog.removeAttribute('open');
btn.classList.remove('active');
});
// Inject token_id before token-rails form submits
document.addEventListener('click', function (e) {
var rails = e.target.closest('button.token-rails');
if (!rails || !window._kitTokenId) return;
var form = rails.closest('form');
if (!form) return;
var existing = form.querySelector('input[name="token_id"]');
if (existing) existing.remove();
var hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = 'token_id';
hidden.value = window._kitTokenId;
form.appendChild(hidden);
if (dialog.hasAttribute('open')) dialog.removeAttribute('open');
});
function attachTooltip(el) {
el.addEventListener('mouseenter', function () {
var tooltip = el.querySelector('.token-tooltip');
if (!tooltip) return;
var rect = el.getBoundingClientRect();
tooltip.style.position = 'fixed';
tooltip.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
tooltip.style.left = rect.left + 'px';
tooltip.style.display = 'block';
});
el.addEventListener('mouseleave', function () {
var tooltip = el.querySelector('.token-tooltip');
if (tooltip) tooltip.style.display = '';
});
}
function attachCardListeners() {
dialog.querySelectorAll('.token[data-token-id]').forEach(function (card) {
card.addEventListener('click', function () {
dialog.querySelectorAll('.token[data-token-id].selected').forEach(function (c) {
c.classList.remove('selected');
});
card.classList.add('selected');
window._kitTokenId = card.dataset.tokenId;
var slot = document.querySelector('.token-slot');
if (slot) slot.classList.add('ready');
});
attachTooltip(card);
});
dialog.querySelectorAll('.kit-bag-deck').forEach(attachTooltip);
}
}());

View File

@@ -0,0 +1,94 @@
const initWallet = () => {
let stripe, elements;
const addBtn = document.getElementById('id_add_payment_method');
const saveBtn = document.getElementById('id_save_payment_method');
const cancelBtn = document.getElementById('id_cancel_payment_method');
if (!addBtn) return;
const getCsrf = () => document.cookie.match(/csrftoken=([^;]+)/)[1];
addBtn.addEventListener('click', async () => {
const res = await fetch('/dashboard/wallet/setup-intent', {
method: 'POST',
headers: {'X-CSRFToken': getCsrf()},
});
const {client_secret, publishable_key} = await res.json();
stripe = Stripe(publishable_key);
elements = stripe.elements({clientSecret: client_secret});
const paymentEl = elements.create('payment');
paymentEl.mount('#id_stripe_payment_element');
saveBtn.hidden = false;
cancelBtn.hidden = false;
const section = addBtn.closest('section');
section.style.setProperty('--applet-rows', '15');
});
saveBtn.addEventListener('click', async () => {
const {error, setupIntent} = await stripe.confirmSetup({
elements,
redirect: 'if_required',
});
if (error) { console.error(error); return; }
const res = await fetch('/dashboard/wallet/save-payment-method', {
method: 'POST',
headers: {
'X-CSRFToken': getCsrf(),
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `payment_method_id=${setupIntent.payment_method}`,
});
const {last4, brand} = await res.json();
const pm = document.createElement('div');
pm.textContent = `${brand} ····${last4}`;
document.getElementById('id_payment_methods').appendChild(pm);
elements.getElement('payment').unmount();
elements = null;
stripe = null;
saveBtn.hidden = true;
cancelBtn.hidden = true;
const section = cancelBtn.closest('section');
section.style.setProperty('--applet-rows', '3');
});
cancelBtn.addEventListener('click', () => {
if (elements) {
elements.getElement('payment').unmount();
elements = null;
stripe = null;
}
saveBtn.hidden = true;
cancelBtn.hidden = true;
const section = cancelBtn.closest('section');
section.style.setProperty('--applet-rows', '3');
});
};
function initWalletTooltips() {
const portal = document.getElementById('id_tooltip_portal');
if (!portal) return;
document.querySelectorAll('.wallet-tokens .token').forEach(token => {
const tooltip = token.querySelector('.token-tooltip');
if (!tooltip) return;
token.addEventListener('mouseenter', () => {
const rect = token.getBoundingClientRect();
portal.innerHTML = tooltip.innerHTML;
portal.classList.add('active');
const halfW = portal.offsetWidth / 2;
const rawLeft = rect.left + rect.width / 2;
const clampedLeft = Math.max(halfW + 8, Math.min(rawLeft, window.innerWidth - halfW - 8));
portal.style.left = Math.round(clampedLeft) + 'px';
portal.style.top = Math.round(rect.top) + 'px';
portal.style.transform = 'translate(-50%, calc(-100% - 0.5rem))';
});
token.addEventListener('mouseleave', () => {
portal.classList.remove('active');
});
});
}
document.addEventListener('DOMContentLoaded', initWallet);
document.addEventListener('DOMContentLoaded', initWalletTooltips);

View File

@@ -1,9 +0,0 @@
// console.log("apps/scripts/dashboard.js loading");
const initialize = (inputSelector) => {
// console.log("initialize called!");
const textInput = document.querySelector(inputSelector);
textInput.oninput = () => {
// console.log("oninput triggered");
textInput.classList.remove("is-invalid");
};
};

View File

@@ -3,39 +3,39 @@ from django.test import TestCase
from apps.dashboard.forms import (
DUPLICATE_ITEM_ERROR,
EMPTY_ITEM_ERROR,
ExistingListItemForm,
ExistingNoteItemForm,
ItemForm,
)
from apps.dashboard.models import Item, List
from apps.dashboard.models import Item, Note
class ItemFormTest(TestCase):
def test_form_save_handles_saving_to_a_list(self):
mylist = List.objects.create()
def test_form_save_handles_saving_to_a_note(self):
mynote = Note.objects.create()
form = ItemForm(data={"text": "do re mi"})
self.assertTrue(form.is_valid())
new_item = form.save(for_list=mylist)
new_item = form.save(for_note=mynote)
self.assertEqual(new_item, Item.objects.get())
self.assertEqual(new_item.text, "do re mi")
self.assertEqual(new_item.list, mylist)
self.assertEqual(new_item.note, mynote)
class ExistingListItemFormTest(TestCase):
class ExistingNoteItemFormTest(TestCase):
def test_form_validation_for_blank_items(self):
list_ = List.objects.create()
form = ExistingListItemForm(for_list=list_, data={"text": ""})
note = Note.objects.create()
form = ExistingNoteItemForm(for_note=note, data={"text": ""})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR])
def test_form_validation_for_duplicate_items(self):
list_ = List.objects.create()
Item.objects.create(list=list_, text="twins, basil")
form = ExistingListItemForm(for_list=list_, data={"text": "twins, basil"})
note = Note.objects.create()
Item.objects.create(note=note, text="twins, basil")
form = ExistingNoteItemForm(for_note=note, data={"text": "twins, basil"})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors["text"], [DUPLICATE_ITEM_ERROR])
def test_form_save(self):
mylist = List.objects.create()
form = ExistingListItemForm(for_list=mylist, data={"text": "howdy"})
mynote = Note.objects.create()
form = ExistingNoteItemForm(for_note=mynote, data={"text": "howdy"})
self.assertTrue(form.is_valid())
new_item = form.save()
self.assertEqual(new_item, Item.objects.get())

View File

@@ -2,69 +2,69 @@ from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
from django.test import TestCase
from apps.dashboard.models import Item, List
from apps.dashboard.models import Item, Note
from apps.lyric.models import User
class ItemModelTest(TestCase):
def test_item_is_related_to_list(self):
mylist = List.objects.create()
def test_item_is_related_to_note(self):
mynote = Note.objects.create()
item = Item()
item.list = mylist
item.note = mynote
item.save()
self.assertIn(item, mylist.item_set.all())
self.assertIn(item, mynote.item_set.all())
def test_cannot_save_null_list_items(self):
mylist = List.objects.create()
item = Item(list=mylist, text=None)
def test_cannot_save_null_note_items(self):
mynote = Note.objects.create()
item = Item(note=mynote, text=None)
with self.assertRaises(IntegrityError):
item.save()
def test_cannot_save_empty_list_items(self):
mylist = List.objects.create()
item = Item(list=mylist, text="")
def test_cannot_save_empty_note_items(self):
mynote = Note.objects.create()
item = Item(note=mynote, text="")
with self.assertRaises(ValidationError):
item.full_clean()
def test_duplicate_items_are_invalid(self):
mylist = List.objects.create()
Item.objects.create(list=mylist, text="jklol")
mynote = Note.objects.create()
Item.objects.create(note=mynote, text="jklol")
with self.assertRaises(ValidationError):
item = Item(list=mylist, text="jklol")
item = Item(note=mynote, text="jklol")
item.full_clean()
def test_still_can_save_same_item_to_different_lists(self):
list1 = List.objects.create()
list2 = List.objects.create()
Item.objects.create(list=list1, text="nojk")
item = Item(list=list2, text="nojk")
def test_still_can_save_same_item_to_different_notes(self):
note1 = Note.objects.create()
note2 = Note.objects.create()
Item.objects.create(note=note1, text="nojk")
item = Item(note=note2, text="nojk")
item.full_clean() # should not raise
class ListModelTest(TestCase):
class NoteModelTest(TestCase):
def test_get_absolute_url(self):
mylist = List.objects.create()
self.assertEqual(mylist.get_absolute_url(), f"/dashboard/list/{mylist.id}/")
mynote = Note.objects.create()
self.assertEqual(mynote.get_absolute_url(), f"/dashboard/note/{mynote.id}/")
def test_list_items_order(self):
list1 = List.objects.create()
item1 = Item.objects.create(list=list1, text="i1")
item2 = Item.objects.create(list=list1, text="item 2")
item3 = Item.objects.create(list=list1, text="3")
def test_note_items_order(self):
note1 = Note.objects.create()
item1 = Item.objects.create(note=note1, text="i1")
item2 = Item.objects.create(note=note1, text="item 2")
item3 = Item.objects.create(note=note1, text="3")
self.assertEqual(
list(list1.item_set.all()),
list(note1.item_set.all()),
[item1, item2, item3],
)
def test_lists_can_have_owners(self):
def test_notes_can_have_owners(self):
user = User.objects.create(email="a@b.cde")
mylist = List.objects.create(owner=user)
self.assertIn(mylist, user.lists.all())
mynote = Note.objects.create(owner=user)
self.assertIn(mynote, user.notes.all())
def test_list_owner_is_optional(self):
List.objects.create()
def test_note_owner_is_optional(self):
Note.objects.create()
def test_list_name_is_first_item_text(self):
list_ = List.objects.create()
Item.objects.create(list=list_, text="first item")
Item.objects.create(list=list_, text="second item")
self.assertEqual(list_.name, "first item")
def test_note_name_is_first_item_text(self):
note = Note.objects.create()
Item.objects.create(note=note, text="first item")
Item.objects.create(note=note, text="second item")
self.assertEqual(note.name, "first item")

View File

@@ -0,0 +1,79 @@
from unittest import mock
from django.test import TestCase
from apps.lyric.models import PaymentMethod, User
class SetupIntentViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="capman@test.io")
self.client.force_login(self.user)
def test_setup_intent_requires_login(self):
self.client.logout()
response = self.client.post("/dashboard/wallet/setup-intent")
self.assertRedirects(
response, "/?next=/dashboard/wallet/setup-intent",
fetch_redirect_response=False,
)
@mock.patch("apps.dashboard.views.stripe")
def test_returns_client_secret(self, mock_stripe):
mock_stripe.Customer.create.return_value = mock.Mock(id="cus_test123")
mock_stripe.SetupIntent.create.return_value = mock.Mock(client_secret="seti_secret")
response = self.client.post("/dashboard/wallet/setup-intent")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()["client_secret"], "seti_secret")
self.assertIn("publishable_key", response.json())
@mock.patch("apps.dashboard.views.stripe")
def test_reuses_existing_stripe_customer(self, mock_stripe):
self.user.stripe_customer_id = "cus_existing"
self.user.save()
mock_stripe.SetupIntent.create.return_value = mock.Mock(client_secret="seti_secret")
self.client.post("/dashboard/wallet/setup-intent")
mock_stripe.Customer.create.assert_not_called()
mock_stripe.SetupIntent.create.assert_called_once_with(customer="cus_existing")
class SavePaymentMethodViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="capman@test.io")
self.user.stripe_customer_id = "cus_test123"
self.user.save()
self.client.force_login(self.user)
def test_save_payment_method_requires_login(self):
self.client.logout()
response = self.client.post(
"/dashboard/wallet/save-payment-method", {"payment_method_id": "pm_test"}
)
self.assertRedirects(
response, "/?next=/dashboard/wallet/save-payment-method",
fetch_redirect_response=False,
)
@mock.patch("apps.dashboard.views.stripe")
def test_creates_payment_method_record(self, mock_stripe):
mock_stripe.PaymentMethod.retrieve.return_value = mock.Mock(
card=mock.Mock(last4="4242", brand="visa")
)
self.client.post(
"/dashboard/wallet/save-payment-method",
{"payment_method_id": "pm_test123"},
)
pm = PaymentMethod.objects.get(user=self.user)
self.assertEqual(pm.last4, "4242")
self.assertEqual(pm.brand, "visa")
@mock.patch("apps.dashboard.views.stripe")
def test_returns_json_with_last4_and_brand(self, mock_stripe):
mock_stripe.PaymentMethod.retrieve.return_value = mock.Mock(
card=mock.Mock(last4="4242", brand="visa")
)
response = self.client.post(
"/dashboard/wallet/save-payment-method",
{"payment_method_id": "pm_test123"},
)
data = response.json()
self.assertEqual(data["last4"], "4242")
self.assertEqual(data["brand"], "visa")

View File

@@ -5,15 +5,21 @@ from django.test import override_settings, TestCase
from django.urls import reverse
from django.utils import html
from apps.applets.models import Applet, UserApplet
from apps.dashboard.forms import (
DUPLICATE_ITEM_ERROR,
EMPTY_ITEM_ERROR,
)
from apps.dashboard.models import Item, List
from apps.dashboard.models import Item, Note
from apps.lyric.models import User
class HomePageTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
Applet.objects.get_or_create(slug="new-note", defaults={"name": "New Note"})
def test_uses_home_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
@@ -22,32 +28,36 @@ class HomePageTest(TestCase):
response = self.client.get('/')
parsed = lxml.html.fromstring(response.content)
forms = parsed.cssselect('form[method=POST]')
self.assertIn("/dashboard/new_list", [form.get("action") for form in forms])
[form] = [form for form in forms if form.get("action") == "/dashboard/new_list"]
self.assertIn("/dashboard/new_note", [form.get("action") for form in forms])
[form] = [form for form in forms if form.get("action") == "/dashboard/new_note"]
inputs = form.cssselect("input")
self.assertIn("text", [input.get("name") for input in inputs])
class NewListTest(TestCase):
class NewNoteTest(TestCase):
def setUp(self):
user = User.objects.create(email="disco@test.io")
self.client.force_login(user)
def test_can_save_a_POST_request(self):
self. client.post("/dashboard/new_list", data={"text": "A new list item"})
self.client.post("/dashboard/new_note", data={"text": "A new note item"})
self.assertEqual(Item.objects.count(), 1)
new_item = Item.objects.get()
self.assertEqual(new_item.text, "A new list item")
self.assertEqual(new_item.text, "A new note item")
def test_redirects_after_POST(self):
response = self.client.post("/dashboard/new_list", data={"text": "A new list item"})
new_list = List.objects.get()
self.assertRedirects(response, f"/dashboard/list/{new_list.id}/")
response = self.client.post("/dashboard/new_note", data={"text": "A new note item"})
new_note = Note.objects.get()
self.assertRedirects(response, f"/dashboard/note/{new_note.id}/")
# Post invalid input helper
def post_invalid_input(self):
return self.client.post("/dashboard/new_list", data={"text": ""})
return self.client.post("/dashboard/new_note", data={"text": ""})
def test_for_invalid_input_nothing_saved_to_db(self):
self.post_invalid_input()
self.assertEqual(Item.objects.count(), 0)
def test_for_invalid_input_renders_list_template(self):
def test_for_invalid_input_renders_home_template(self):
response = self.post_invalid_input()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "apps/dashboard/home.html")
@@ -56,15 +66,16 @@ class NewListTest(TestCase):
response = self.post_invalid_input()
self.assertContains(response, html.escape(EMPTY_ITEM_ERROR))
class ListViewTest(TestCase):
def test_uses_list_template(self):
mylist = List.objects.create()
response = self.client.get(f"/dashboard/list/{mylist.id}/")
self.assertTemplateUsed(response, "apps/dashboard/list.html")
@override_settings(COMPRESS_ENABLED=False)
class NoteViewTest(TestCase):
def test_uses_note_template(self):
mynote = Note.objects.create()
response = self.client.get(f"/dashboard/note/{mynote.id}/")
self.assertTemplateUsed(response, "apps/dashboard/note.html")
def test_renders_input_form(self):
mylist = List.objects.create()
url = f"/dashboard/list/{mylist.id}/"
mynote = Note.objects.create()
url = f"/dashboard/note/{mynote.id}/"
response = self.client.get(url)
parsed = lxml.html.fromstring(response.content)
forms = parsed.cssselect("form[method=POST]")
@@ -73,58 +84,58 @@ class ListViewTest(TestCase):
inputs = form.cssselect("input")
self.assertIn("text", [input.get("name") for input in inputs])
def test_displays_only_items_for_that_list(self):
def test_displays_only_items_for_that_note(self):
# Given/Arrange
correct_list = List.objects.create()
Item.objects.create(text="itemey 1", list=correct_list)
Item.objects.create(text="itemey 2", list=correct_list)
other_list = List.objects.create()
Item.objects.create(text="other list item", list=other_list)
correct_note = Note.objects.create()
Item.objects.create(text="itemey 1", note=correct_note)
Item.objects.create(text="itemey 2", note=correct_note)
other_note = Note.objects.create()
Item.objects.create(text="other note item", note=other_note)
# When/Act
response = self.client.get(f"/dashboard/list/{correct_list.id}/")
response = self.client.get(f"/dashboard/note/{correct_note.id}/")
# Then/Assert
self.assertContains(response, "itemey 1")
self.assertContains(response, "itemey 2")
self.assertNotContains(response, "other list item")
self.assertNotContains(response, "other note item")
def test_can_save_a_POST_request_to_an_existing_list(self):
other_list = List.objects.create()
correct_list = List.objects.create()
def test_can_save_a_POST_request_to_an_existing_note(self):
other_note = Note.objects.create()
correct_note = Note.objects.create()
self.client.post(
f"/dashboard/list/{correct_list.id}/",
data={"text": "A new item for an existing list"},
f"/dashboard/note/{correct_note.id}/",
data={"text": "A new item for an existing note"},
)
self.assertEqual(Item.objects.count(), 1)
new_item = Item.objects.get()
self.assertEqual(new_item.text, "A new item for an existing list")
self.assertEqual(new_item.list, correct_list)
self.assertEqual(new_item.text, "A new item for an existing note")
self.assertEqual(new_item.note, correct_note)
def test_POST_redirects_to_list_view(self):
other_list = List.objects.create()
correct_list = List.objects.create()
def test_POST_redirects_to_note_view(self):
other_note = Note.objects.create()
correct_note = Note.objects.create()
response = self.client.post(
f"/dashboard/list/{correct_list.id}/",
data={"text": "A new item for an existing list"},
f"/dashboard/note/{correct_note.id}/",
data={"text": "A new item for an existing note"},
)
self.assertRedirects(response, f"/dashboard/list/{correct_list.id}/")
self.assertRedirects(response, f"/dashboard/note/{correct_note.id}/")
# Post invalid input helper
def post_invalid_input(self):
mylist = List.objects.create()
return self.client.post(f"/dashboard/list/{mylist.id}/", data={"text": ""})
mynote = Note.objects.create()
return self.client.post(f"/dashboard/note/{mynote.id}/", data={"text": ""})
def test_for_invalid_input_nothing_saved_to_db(self):
self.post_invalid_input()
self.assertEqual(Item.objects.count(), 0)
def test_for_invalid_input_renders_list_template(self):
def test_for_invalid_input_renders_note_template(self):
response = self.post_invalid_input()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "apps/dashboard/list.html")
self.assertTemplateUsed(response, "apps/dashboard/note.html")
def test_for_invalid_input_shows_error_on_page(self):
response = self.post_invalid_input()
@@ -136,26 +147,26 @@ class ListViewTest(TestCase):
[input] = parsed.cssselect("input[name=text]")
self.assertIn("is-invalid", set(input.classes))
def test_duplicate_item_validation_errors_end_up_on_lists_page(self):
list1 = List.objects.create()
Item.objects.create(list=list1, text="lorem ipsum")
def test_duplicate_item_validation_errors_end_up_on_note_page(self):
note1 = Note.objects.create()
Item.objects.create(note=note1, text="lorem ipsum")
response = self.client.post(
f"/dashboard/list/{list1.id}/",
f"/dashboard/note/{note1.id}/",
data={"text": "lorem ipsum"},
)
expected_error = html.escape(DUPLICATE_ITEM_ERROR)
self.assertContains(response, expected_error)
self.assertTemplateUsed(response, "apps/dashboard/list.html")
self.assertTemplateUsed(response, "apps/dashboard/note.html")
self.assertEqual(Item.objects.all().count(), 1)
class MyListsTest(TestCase):
def test_my_lists_url_renders_my_lists_template(self):
class MyNotesTest(TestCase):
def test_my_notes_url_renders_my_notes_template(self):
user = User.objects.create(email="a@b.cde")
self.client.force_login(user)
response = self.client.get(f"/dashboard/users/{user.id}/")
self.assertTemplateUsed(response, "apps/dashboard/my_lists.html")
self.assertTemplateUsed(response, "apps/dashboard/my_notes.html")
def test_passes_correct_owner_to_template(self):
User.objects.create(email="wrongowner@example.com")
@@ -164,20 +175,20 @@ class MyListsTest(TestCase):
response = self.client.get(f"/dashboard/users/{correct_user.id}/")
self.assertEqual(response.context["owner"], correct_user)
def test_list_owner_is_saved_if_user_is_authenticated(self):
def test_note_owner_is_saved_if_user_is_authenticated(self):
user = User.objects.create(email="a@b.cde")
self.client.force_login(user)
self.client.post("/dashboard/new_list", data={"text": "new item"})
new_list = List.objects.get()
self.assertEqual(new_list.owner, user)
self.client.post("/dashboard/new_note", data={"text": "new item"})
new_note = Note.objects.get()
self.assertEqual(new_note.owner, user)
def test_my_lists_redirects_if_not_logged_in(self):
def test_my_notes_redirects_if_not_logged_in(self):
user = User.objects.create(email="a@b.cde")
response = self.client.get(f"/dashboard/users/{user.id}/")
self.assertRedirects(response, "/")
def test_my_lists_returns_403_for_wrong_user(self):
# create two users, login as user_a, request user_b's my_lists url
def test_my_notes_returns_403_for_wrong_user(self):
# create two users, login as user_a, request user_b's my_notes url
user1 = User.objects.create(email="a@b.cde")
user2 = User.objects.create(email="wrongowner@example.com")
self.client.force_login(user2)
@@ -185,46 +196,50 @@ class MyListsTest(TestCase):
# assert 403
self.assertEqual(response.status_code, 403)
class ShareListTest(TestCase):
def test_post_to_share_list_url_redirects_to_list(self):
our_list = List.objects.create()
class ShareNoteTest(TestCase):
def test_post_to_share_note_url_redirects_to_note(self):
our_note = Note.objects.create()
alice = User.objects.create(email="alice@example.com")
response = self.client.post(
f"/dashboard/list/{our_list.id}/share_list",
f"/dashboard/note/{our_note.id}/share_note",
data={"recipient": "alice@example.com"},
)
self.assertRedirects(response, f"/dashboard/list/{our_list.id}/")
self.assertRedirects(response, f"/dashboard/note/{our_note.id}/")
def test_post_with_email_adds_user_to_shared_with(self):
our_list = List.objects.create()
our_note = Note.objects.create()
alice = User.objects.create(email="alice@example.com")
self.client.post(
f"/dashboard/list/{our_list.id}/share_list",
f"/dashboard/note/{our_note.id}/share_note",
data={"recipient": "alice@example.com"},
)
self.assertIn(alice, our_list.shared_with.all())
self.assertIn(alice, our_note.shared_with.all())
def test_post_with_nonexistent_email_redirects_to_list(self):
our_list = List.objects.create()
def test_post_with_nonexistent_email_redirects_to_note(self):
our_note = Note.objects.create()
response = self.client.post(
f"/dashboard/list/{our_list.id}/share_list",
f"/dashboard/note/{our_note.id}/share_note",
data={"recipient": "nobody@example.com"},
)
self.assertRedirects(response, f"/dashboard/list/{our_list.id}/")
self.assertRedirects(
response,
f"/dashboard/note/{our_note.id}/",
fetch_redirect_response=False,
)
def test_share_list_does_not_add_owner_as_recipient(self):
def test_share_note_does_not_add_owner_as_recipient(self):
owner = User.objects.create(email="owner@example.com")
our_list = List.objects.create(owner=owner)
our_note = Note.objects.create(owner=owner)
self.client.force_login(owner)
self.client.post(reverse("share_list", args=[our_list.id]),
self.client.post(reverse("share_note", args=[our_note.id]),
data={"recipient": "owner@example.com"})
self.assertNotIn(owner, our_list.shared_with.all())
self.assertNotIn(owner, our_note.shared_with.all())
@override_settings(MESSAGE_STORAGE='django.contrib.messages.storage.session.SessionStorage')
def test_share_list_shows_privacy_safe_message(self):
our_list = List.objects.create()
def test_share_note_shows_privacy_safe_message(self):
our_note = Note.objects.create()
response = self.client.post(
f"/dashboard/list/{our_list.id}/share_list",
f"/dashboard/note/{our_note.id}/share_note",
data={"recipient": "nobody@example.com"},
follow=True,
)
@@ -234,24 +249,236 @@ class ShareListTest(TestCase):
"An invite has been sent if that address is registered.",
)
class ViewAuthListTest(TestCase):
class ViewAuthNoteTest(TestCase):
def setUp(self):
self.owner = User.objects.create(email="disco@example.com")
self.our_list = List.objects.create(owner=self.owner)
self.our_note = Note.objects.create(owner=self.owner)
def test_anonymous_user_is_redirected(self):
response = self.client.get(reverse("view_list", args=[self.our_list.id]))
self.assertRedirects(response, "/")
response = self.client.get(reverse("view_note", args=[self.our_note.id]))
self.assertRedirects(response, "/", fetch_redirect_response=False)
def test_non_owner_non_shared_user_gets_403(self):
stranger = User.objects.create(email="stranger@example.com")
self.client.force_login(stranger)
response = self.client.get(reverse("view_list", args=[self.our_list.id]))
response = self.client.get(reverse("view_note", args=[self.our_note.id]))
self.assertEqual(response.status_code, 403)
def test_shared_with_user_can_access_list(self):
def test_shared_with_user_can_access_note(self):
guest = User.objects.create(email="guest@example.com")
self.our_list.shared_with.add(guest)
self.our_note.shared_with.add(guest)
self.client.force_login(guest)
response = self.client.get(reverse("view_list", args=[self.our_list.id]))
response = self.client.get(reverse("view_note", args=[self.our_note.id]))
self.assertEqual(response.status_code, 200)
@override_settings(COMPRESS_ENABLED=False)
class SetPaletteTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="a@b.cde")
self.client.force_login(self.user)
self.url = reverse("home")
Applet.objects.get_or_create(slug="palette", defaults={"name": "Palette"})
def test_anonymous_user_is_redirected_home(self):
response = self.client.post("/dashboard/set_palette")
self.assertRedirects(response, "/", fetch_redirect_response=False)
def test_set_palette_updates_user_palette(self):
User.objects.filter(pk=self.user.pk).update(palette="palette-sheol")
self.client.post("/dashboard/set_palette", data={"palette": "palette-default"})
self.user.refresh_from_db()
self.assertEqual(self.user.palette, "palette-default")
def test_locked_palette_is_rejected(self):
response = self.client.post("/dashboard/set_palette", data={"palette": "palette-nirvana"})
self.user.refresh_from_db()
self.assertEqual(self.user.palette, "palette-default")
self.assertRedirects(response, "/", fetch_redirect_response=False)
def test_set_palette_redirects_home(self):
response = self.client.post("/dashboard/set_palette", data={"palette": "palette-default"})
self.assertRedirects(response, "/", fetch_redirect_response=False)
def test_set_palette_returns_json_when_requested(self):
response = self.client.post(
"/dashboard/set_palette",
data={"palette": "palette-sepia"},
headers={"Accept": "application/json"},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {"palette": "palette-sepia"})
def test_locked_palette_returns_unchanged_json(self):
response = self.client.post(
"/dashboard/set_palette",
data={"palette": "palette-nirvana"},
headers={"Accept": "application/json"},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {"palette": "palette-default"})
def test_dashboard_contains_set_palette_form(self):
response = self.client.get(self.url)
parsed = lxml.html.fromstring(response.content)
forms = parsed.cssselect('form[action="/dashboard/set_palette"]')
unlocked = [p for p in response.context["palettes"] if not p["locked"]]
self.assertEqual(len(forms), len(unlocked))
def test_active_palette_swatch_has_active_class(self):
response = self.client.get(self.url)
parsed = lxml.html.fromstring(response.content)
[active] = parsed.cssselect(".swatch.active")
self.assertIn("palette-default", active.classes)
def test_locked_palettes_are_not_forms(self):
response = self.client.get(self.url)
parsed = lxml.html.fromstring(response.content)
locked = parsed.cssselect(".swatch.locked")
expected_locked = [p for p in response.context["palettes"] if p["locked"]]
self.assertEqual(len(locked), len(expected_locked))
# they mustn't be button els
for swatch in locked:
self.assertNotEqual(swatch.tag, "button")
def test_palette_picker_count_matches_context(self):
response = self.client.get(self.url)
parsed = lxml.html.fromstring(response.content)
swatches = parsed.cssselect(".swatch")
self.assertEqual(len(swatches), len(response.context["palettes"]))
@override_settings(COMPRESS_ENABLED=False)
class ProfileViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="discoman@example.com")
self.client.force_login(self.user)
def test_post_username_saves_to_user(self):
self.client.post("/dashboard/set_profile", data={"username": "discoman"})
self.user.refresh_from_db()
self.assertEqual(self.user.username, "discoman")
def test_post_username_requires_login(self):
self.client.logout()
response = self.client.post("/dashboard/set_profile", data={"username": "somnambulist"})
self.assertRedirects(response, "/?next=/dashboard/set_profile", fetch_redirect_response=False)
def test_dash_renders_username_applet(self):
response = self.client.get("/")
parsed = lxml.html.fromstring(response.content)
[applet] = parsed.cssselect("#id_applet_username")
self.assertIn("@", applet.text_content())
[input_el] = parsed.cssselect("#id_new_username")
self.assertEqual("", input_el.get("value"))
def test_dash_shows_display_name_in_applet(self):
self.user.username = "discoman"
self.user.save()
response = self.client.get("/")
parsed = lxml.html.fromstring(response.content)
[username_input] = parsed.cssselect("#id_new_username")
self.assertEqual("discoman", username_input.get("value"))
class ToggleDashAppletsViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
self.username_applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username"})
self.palette_applet, _ = Applet.objects.get_or_create(slug="palette", defaults={"name": "Palette"})
self.url = reverse("toggle_applets")
def test_unauthenticated_user_is_redirected(self):
self.client.logout()
response = self.client.post(self.url)
self.assertRedirects(
response, f"/?next={self.url}", fetch_redirect_response=False
)
def test_unchecked_applet_gets_user_applet_with_visible_false(self):
self.client.post(self.url, {"applets": ["username"]})
ua = UserApplet.objects.get(user=self.user, applet=self.palette_applet)
self.assertFalse(ua.visible)
def test_redirects_on_normal_post(self):
response = self.client.post(
self.url, {"applets": ["username", "palette"]}
)
self.assertRedirects(response, reverse("home"), fetch_redirect_response=False)
def test_returns_200_on_htmx_post(self):
response = self.client.post(
self.url,
{"applets": ["username", "palette"]},
HTTP_HX_REQUEST="true",
)
self.assertEqual(response.status_code, 200)
def test_htmx_post_renders_visible_applets_only(self):
response = self.client.post(
self.url,
{"applets": ["username"]},
HTTP_HX_REQUEST="true",
)
parsed = lxml.html.fromstring(response.content)
self.assertEqual(len(parsed.cssselect("#id_applet_username")), 1)
self.assertEqual(len(parsed.cssselect("#id_applet_palette")), 0)
def test_toggle_applets_does_not_affect_gameboard_applets(self):
game_applet, _ = Applet.objects.get_or_create(
slug="new-game", defaults={"name": "New Game", "context": "gameboard"}
)
self.client.post(self.url, {"applets": ["username", "palette"]})
self.assertFalse(UserApplet.objects.filter(user=self.user, applet=game_applet). exists())
class AppletVisibilityContextTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
self.username_applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username"})
self.palette_applet, _ = Applet.objects.get_or_create(slug="palette", defaults={"name": "Palette"})
UserApplet.objects.create(user=self.user, applet=self.palette_applet, visible=False)
def test_dash_reflects_user_applet_visibility(self):
response = self.client.get("/")
applet_map = {entry["applet"].slug: entry["visible"] for entry in response.context["applets"]}
self.assertFalse(applet_map["palette"])
self.assertTrue(applet_map["username"])
class FooterNavTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
def test_footer_nav_present_on_dashboard(self):
response = self.client.get("/")
parsed = lxml.html.fromstring(response.content)
[nav] = parsed.cssselect("#id_footer_nav")
self.assertIsNotNone(nav)
def test_footer_nav_has_dashboard_link(self):
response = self.client.get("/")
parsed = lxml.html.fromstring(response.content)
[nav] = parsed.cssselect("#id_footer_nav")
links = [a.get("href") for a in nav.cssselect("a")]
self.assertIn("/", links)
def test_footer_nav_has_gameboard_link(self):
response = self.client.get("/")
parsed = lxml.html.fromstring(response.content)
[nav] = parsed.cssselect("#id_footer_nav")
links = [a.get("href") for a in nav.cssselect("a")]
self.assertIn("/gameboard/", links)
class WalletAppletTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
Applet.objects.get_or_create(slug="wallet", defaults={"name": "Wallet"})
response = self.client.get("/")
self.parsed = lxml.html.fromstring(response.content)
def test_wallet_applet_present_on_dash(self):
[_] = self.parsed.cssselect("#id_applet_wallet")
def test_wallet_applet_has_manage_link(self):
[link] = self.parsed.cssselect("#id_applet_wallet a.wallet-manage-link")
self.assertEqual(link.get("href"), "/dashboard/wallet/")

View File

@@ -0,0 +1,139 @@
import lxml.html
from django.test import TestCase
from apps.applets.models import Applet, UserApplet
from apps.lyric.models import Token, User, Wallet
class WalletViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="capman@test.io")
self.client.force_login(self.user)
response = self.client.get("/dashboard/wallet/")
self.parsed = lxml.html.fromstring(response.content)
def test_wallet_page_requires_login(self):
self.client.logout()
response = self.client.get("/dashboard/wallet/")
self.assertRedirects(
response, "/?next=/dashboard/wallet/", fetch_redirect_response=False
)
def test_wallet_page_renders(self):
[el] = self.parsed.cssselect("#id_writs_balance")
self.assertEqual(el.text_content().strip(), "144")
def test_wallet_page_shows_esteem_balance(self):
[el] = self.parsed.cssselect("#id_esteem_balance")
self.assertEqual(el.text_content().strip(), "0")
def test_wallet_page_shows_coin_on_a_string(self):
[_] = self.parsed.cssselect("#id_coin_on_a_string")
def test_wallet_page_shows_free_token(self):
[_] = self.parsed.cssselect("#id_free_token")
def test_wallet_page_shows_payment_methods_section(self):
[_] = self.parsed.cssselect("#id_add_payment_method")
def test_wallet_page_shows_stripe_payment_element(self):
[_] = self.parsed.cssselect("#id_stripe_payment_element")
def test_wallet_page_shows_tithe_token_shop(self):
[_] = self.parsed.cssselect("#id_tithe_token_shop")
def test_tithe_token_shop_shows_bundle(self):
bundles = self.parsed.cssselect("#id_tithe_token_shop .token-bundle")
self.assertGreater(len(bundles), 0)
class WalletViewAppletContextTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="walletctx@test.io")
Applet.objects.get_or_create(
slug="wallet-balances",
defaults={"name": "Wallet Balances", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
)
Applet.objects.get_or_create(
slug="wallet-tokens",
defaults={"name": "Wallet Tokens", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
)
Applet.objects.get_or_create(
slug="wallet-payment",
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 3, "context": "wallet"},
)
self.client.force_login(self.user)
def test_wallet_view_passes_applets_context(self):
response = self.client.get("/dashboard/wallet/")
slugs = [e["applet"].slug for e in response.context["applets"]]
self.assertIn("wallet-balances", slugs)
self.assertIn("wallet-tokens", slugs)
self.assertIn("wallet-payment", slugs)
def test_wallet_page_renders_applets_container(self):
response = self.client.get("/dashboard/wallet/")
parsed = lxml.html.fromstring(response.content)
[_] = parsed.cssselect("#id_wallet_applets_container")
def test_wallet_page_renders_gear_button(self):
response = self.client.get("/dashboard/wallet/")
parsed = lxml.html.fromstring(response.content)
[_] = parsed.cssselect(".gear-btn")
class ToggleWalletAppletsTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="wallettoggle@test.io")
self.balances = Applet.objects.get_or_create(
slug="wallet-balances",
defaults={"name": "Wallet Balances", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
)[0]
self.tokens = Applet.objects.get_or_create(
slug="wallet-tokens",
defaults={"name": "Wallet Tokens", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
)[0]
Applet.objects.get_or_create(
slug="wallet-payment",
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 3, "context": "wallet"},
)
self.client.force_login(self.user)
def test_toggle_requires_login(self):
self.client.logout()
response = self.client.post("/dashboard/wallet/toggle-applets", {})
self.assertRedirects(
response, "/?next=/dashboard/wallet/toggle-applets",
fetch_redirect_response=False,
)
def test_toggle_redirects_to_wallet(self):
response = self.client.post(
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
)
self.assertRedirects(response, "/dashboard/wallet/", fetch_redirect_response=False)
def test_toggle_hides_unchecked_applet(self):
self.client.post(
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
)
ua = UserApplet.objects.get(user=self.user, applet=self.tokens)
self.assertFalse(ua.visible)
def test_toggle_shows_checked_applet(self):
UserApplet.objects.create(user=self.user, applet=self.balances, visible=False)
self.client.post(
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
)
ua = UserApplet.objects.get(user=self.user, applet=self.balances)
self.assertTrue(ua.visible)
def test_toggle_htmx_returns_container_partial(self):
response = self.client.post(
"/dashboard/wallet/toggle-applets",
{"applets": ["wallet-balances"]},
HTTP_HX_REQUEST="true",
)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "id_wallet_applets_container")

View File

@@ -0,0 +1,9 @@
from datetime import date
from django.test import SimpleTestCase
from django.template.loader import render_to_string
class FooterTemplateTest(SimpleTestCase):
def test_footer_shows_current_year(self):
rendered = render_to_string("core/_partials/_footer.html")
self.assertIn(str(date.today().year), rendered)

View File

@@ -2,8 +2,16 @@ from django.urls import path
from . import views
urlpatterns = [
path('new_list', views.new_list, name='new_list'),
path('list/<uuid:list_id>/', views.view_list, name='view_list'),
path('users/<uuid:user_id>/', views.my_lists, name='my_lists'),
path('list/<uuid:list_id>/share_list', views.share_list, name="share_list"),
path('new_note', views.new_note, name='new_note'),
path('note/<uuid:note_id>/', views.view_note, name='view_note'),
path('note/<uuid:note_id>/share_note', views.share_note, name="share_note"),
path('set_palette', views.set_palette, name='set_palette'),
path('set_profile', views.set_profile, name='set_profile'),
path('users/<uuid:user_id>/', views.my_notes, name='my_notes'),
path('toggle_applets', views.toggle_applets, name="toggle_applets"),
path('wallet/', views.wallet, name='wallet'),
path('wallet/toggle-applets', views.toggle_wallet_applets, name='toggle_wallet_applets'),
path('wallet/setup-intent', views.setup_intent, name='setup_intent'),
path('wallet/save-payment-method', views.save_payment_method, name='save_payment_method'),
path('kit-bag/', views.kit_bag, name='kit_bag'),
]

View File

@@ -1,61 +1,238 @@
import stripe
from django.conf import settings
from django.contrib import messages
from django.http import HttpResponseForbidden
from django.contrib.auth.decorators import login_required
from django.db.models import Max, Q
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
from django.shortcuts import redirect, render
from django.utils import timezone
from django.views.decorators.csrf import ensure_csrf_cookie
from .forms import ExistingListItemForm, ItemForm
from .models import Item, List
from apps.lyric.models import User
from apps.applets.models import Applet, UserApplet
from apps.applets.utils import applet_context
from apps.dashboard.forms import ExistingNoteItemForm, ItemForm
from apps.dashboard.models import Item, Note
from apps.lyric.models import PaymentMethod, Token, User, Wallet
APPLET_ORDER = ["wallet", "new-note", "my-notes", "username", "palette"]
UNLOCKED_PALETTES = frozenset([
"palette-default",
"palette-sepia",
"palette-oblivion-light",
"palette-monochrome-dark",
])
PALETTES = [
{"name": "palette-default", "label": "Earthman", "locked": False},
{"name": "palette-sepia", "label": "Sepia", "locked": False},
{"name": "palette-oblivion-light", "label": "Oblivion (Light)", "locked": False},
{"name": "palette-monochrome-dark", "label": "Monochrome (Dark)", "locked": False},
{"name": "palette-nirvana", "label": "Nirvana", "locked": True},
{"name": "palette-sheol", "label": "Sheol", "locked": True},
{"name": "palette-inferno", "label": "Inferno", "locked": True},
{"name": "palette-terrestre", "label": "Terrestre", "locked": True},
{"name": "palette-celestia", "label": "Celestia", "locked": True},
]
def _recent_notes(user, limit=3):
return (
Note
.objects
.filter(Q(owner=user) | Q(shared_with=user))
.annotate(last_item=Max('item__id'))
.order_by('-last_item')
.distinct()[:limit]
)
def home_page(request):
return render(request, "apps/dashboard/home.html", {"form": ItemForm()})
context = {
"form": ItemForm(),
"palettes": PALETTES,
"page_class": "page-dashboard",
}
if request.user.is_authenticated:
context["applets"] = applet_context(request.user, "dashboard")
context["recent_notes"] = _recent_notes(request.user)
return render(request, "apps/dashboard/home.html", context)
def new_list(request):
def new_note(request):
form = ItemForm(data=request.POST)
if form.is_valid():
nulist = List.objects.create()
nunote = Note.objects.create()
if request.user.is_authenticated:
nulist.owner = request.user
nulist.save()
form.save(for_list=nulist)
return redirect(nulist)
nunote.owner = request.user
nunote.save()
form.save(for_note=nunote)
return redirect(nunote)
else:
return render(request, "apps/dashboard/home.html", {"form": form})
context = {
"form": form,
"palettes": PALETTES,
"page_class": "page-dashboard",
}
if request.user.is_authenticated:
context["applets"] = applet_context(request.user, "dashboard")
context["recent_notes"] = _recent_notes(request.user)
return render(request, "apps/dashboard/home.html", context)
def view_list(request, list_id):
our_list = List.objects.get(id=list_id)
def view_note(request, note_id):
our_note = Note.objects.get(id=note_id)
if our_list.owner:
if our_note.owner:
if not request.user.is_authenticated:
return redirect("/")
if request.user != our_list.owner and request.user not in our_list.shared_with.all():
if request.user != our_note.owner and request.user not in our_note.shared_with.all():
return HttpResponseForbidden()
form = ExistingListItemForm(for_list=our_list)
form = ExistingNoteItemForm(for_note=our_note)
if request.method == "POST":
form = ExistingListItemForm(for_list=our_list, data=request.POST)
form = ExistingNoteItemForm(for_note=our_note, data=request.POST)
if form.is_valid():
form.save()
return redirect(our_list)
return render(request, "apps/dashboard/list.html", {"list": our_list, "form": form})
return redirect(our_note)
return render(request, "apps/dashboard/note.html", {"note": our_note, "form": form})
def my_lists(request, user_id):
def my_notes(request, user_id):
owner = User.objects.get(id=user_id)
if not request.user.is_authenticated:
return redirect("/")
if request.user.id != owner.id:
return HttpResponseForbidden()
return render(request, "apps/dashboard/my_lists.html", {"owner": owner})
return render(request, "apps/dashboard/my_notes.html", {"owner": owner})
def share_list(request, list_id):
our_list = List.objects.get(id=list_id)
def share_note(request, note_id):
our_note = Note.objects.get(id=note_id)
try:
recipient = User.objects.get(email=request.POST["recipient"])
if recipient == request.user:
return redirect(our_list)
our_list.shared_with.add(recipient)
return redirect(our_note)
our_note.shared_with.add(recipient)
except User.DoesNotExist:
pass
messages.success(request, "An invite has been sent if that address is registered.")
return redirect(our_list)
return redirect(our_note)
@login_required(login_url="/")
def set_palette(request):
if request.method == "POST":
palette = request.POST.get("palette", "")
if palette in UNLOCKED_PALETTES:
request.user.palette = palette
request.user.save(update_fields=["palette"])
if "application/json" in request.headers.get("Accept", ""):
return JsonResponse({"palette": request.user.palette})
return redirect("home")
@login_required(login_url="/")
def set_profile(request):
if request.method == "POST":
username = request.POST.get("username", "")
request.user.username = username
request.user.save(update_fields=["username"])
return redirect("/")
@login_required(login_url="/")
def toggle_applets(request):
checked = request.POST.getlist("applets")
for applet in Applet.objects.filter(context="dashboard"):
UserApplet.objects.update_or_create(
user=request.user,
applet=applet,
defaults={"visible": applet.slug in checked},
)
if request.headers.get("HX-Request"):
return render(request, "apps/dashboard/_partials/_applets.html", {
"applets": applet_context(request.user, "dashboard"),
"palettes": PALETTES,
"form": ItemForm(),
"recent_notes": _recent_notes(request.user),
})
return redirect("home")
@login_required(login_url="/")
@ensure_csrf_cookie
def wallet(request):
return render(request, "apps/dashboard/wallet.html", {
"wallet": request.user.wallet,
"pass_token": request.user.tokens.filter(token_type=Token.PASS).first(),
"coin": request.user.tokens.filter(token_type=Token.COIN).first(),
"free_tokens": list(request.user.tokens.filter(
token_type=Token.FREE, expires_at__gt=timezone.now()
).order_by("expires_at")),
"tithe_tokens": list(request.user.tokens.filter(token_type=Token.TITHE)),
"free_count": request.user.tokens.filter(
token_type=Token.FREE, expires_at__gt=timezone.now()
).count(),
"tithe_count": request.user.tokens.filter(token_type=Token.TITHE).count(),
"applets": applet_context(request.user, "wallet"),
"page_class": "page-wallet",
})
@login_required(login_url="/")
def kit_bag(request):
tokens = list(request.user.tokens.all())
free_tokens = sorted(
[t for t in tokens if t.token_type == Token.FREE and t.expires_at and t.expires_at > timezone.now()],
key=lambda t: t.expires_at,
)
tithe_tokens = [t for t in tokens if t.token_type == Token.TITHE]
return render(request, "core/_partials/_kit_bag_panel.html", {
"equipped_deck": request.user.equipped_deck,
"equipped_trinket": request.user.equipped_trinket,
"free_token": free_tokens[0] if free_tokens else None,
"free_count": len(free_tokens),
"tithe_token": tithe_tokens[0] if tithe_tokens else None,
"tithe_count": len(tithe_tokens),
})
@login_required(login_url="/")
def toggle_wallet_applets(request):
checked = request.POST.getlist("applets")
for applet in Applet.objects.filter(context="wallet"):
UserApplet.objects.update_or_create(
user=request.user,
applet=applet,
defaults={"visible": applet.slug in checked},
)
if request.headers.get("HX-Request"):
return render(request, "apps/wallet/_partials/_applets.html", {
"applets": applet_context(request.user, "wallet"),
"wallet": request.user.wallet,
"pass_token": request.user.tokens.filter(token_type=Token.PASS).first(),
"coin": request.user.tokens.filter(token_type=Token.COIN).first(),
"free_tokens": list(request.user.tokens.filter(token_type=Token.FREE)),
"tithe_tokens": list(request.user.tokens.filter(token_type=Token.TITHE)),
})
return redirect("wallet")
@login_required(login_url="/")
def setup_intent(request):
stripe.api_key = settings.STRIPE_SECRET_KEY
user = request.user
if not user.stripe_customer_id:
customer = stripe.Customer.create(email=user.email)
user.stripe_customer_id = customer.id
user.save(update_fields=["stripe_customer_id"])
intent = stripe.SetupIntent.create(customer=user.stripe_customer_id)
return JsonResponse({
"client_secret": intent.client_secret,
"publishable_key": settings.STRIPE_PUBLISHABLE_KEY,
})
@login_required(login_url="/")
def save_payment_method(request):
stripe.api_key = settings.STRIPE_SECRET_KEY
pm_id = request.POST.get("payment_method_id")
pm = stripe.PaymentMethod.retrieve(pm_id)
stripe.PaymentMethod.attach(pm_id, customer=request.user.stripe_customer_id)
PaymentMethod.objects.create(
user=request.user,
stripe_pm_id=pm_id,
last4=pm.card.last4,
brand=pm.card.brand,
)
return JsonResponse({"last4": pm.card.last4, "brand": pm.card.brand})

View File

19
src/apps/drama/admin.py Normal file
View File

@@ -0,0 +1,19 @@
from django.contrib import admin
from apps.drama.models import GameEvent
@admin.register(GameEvent)
class GameEventAdmin(admin.ModelAdmin):
list_display = ("timestamp", "room", "actor", "verb")
list_filter = ("verb",)
readonly_fields = ("room", "actor", "verb", "data", "timestamp")
def has_add_permission(self, request):
return False
def has_delete_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False

6
src/apps/drama/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class DramaConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.drama'

View File

@@ -0,0 +1,32 @@
# Generated by Django 6.0 on 2026-03-19 18:34
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('epic', '0006_table_status_and_table_seat'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='GameEvent',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('verb', models.CharField(choices=[('room_created', 'Room created'), ('slot_reserved', 'Gate slot reserved'), ('slot_filled', 'Gate slot filled'), ('slot_returned', 'Gate slot returned'), ('slot_released', 'Gate slot released'), ('invite_sent', 'Invite sent'), ('role_select_started', 'Role select started'), ('role_selected', 'Role selected'), ('roles_revealed', 'Roles revealed')], max_length=30)),
('data', models.JSONField(default=dict)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('actor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='game_events', to=settings.AUTH_USER_MODEL)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='events', to='epic.room')),
],
options={
'ordering': ['timestamp'],
},
),
]

View File

@@ -0,0 +1,30 @@
# Generated by Django 6.0 on 2026-03-24 21:36
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('drama', '0001_initial'),
('epic', '0006_table_status_and_table_seat'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='ScrollPosition',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('position', models.PositiveIntegerField(default=0)),
('updated_at', models.DateTimeField(auto_now=True)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scroll_positions', to='epic.room')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scroll_positions', to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('user', 'room')},
},
),
]

View File

136
src/apps/drama/models.py Normal file
View File

@@ -0,0 +1,136 @@
from django.conf import settings
from django.db import models
class GameEvent(models.Model):
# Gate phase
ROOM_CREATED = "room_created"
SLOT_RESERVED = "slot_reserved"
SLOT_FILLED = "slot_filled"
SLOT_RETURNED = "slot_returned"
SLOT_RELEASED = "slot_released"
INVITE_SENT = "invite_sent"
# Role Select phase
ROLE_SELECT_STARTED = "role_select_started"
ROLE_SELECTED = "role_selected"
ROLES_REVEALED = "roles_revealed"
VERB_CHOICES = [
(ROOM_CREATED, "Room created"),
(SLOT_RESERVED, "Gate slot reserved"),
(SLOT_FILLED, "Gate slot filled"),
(SLOT_RETURNED, "Gate slot returned"),
(SLOT_RELEASED, "Gate slot released"),
(INVITE_SENT, "Invite sent"),
(ROLE_SELECT_STARTED, "Role select started"),
(ROLE_SELECTED, "Role selected"),
(ROLES_REVEALED, "Roles revealed"),
]
room = models.ForeignKey(
"epic.Room", on_delete=models.CASCADE, related_name="events",
)
actor = models.ForeignKey(
settings.AUTH_USER_MODEL, null=True, blank=True,
on_delete=models.SET_NULL, related_name="game_events",
)
verb = models.CharField(max_length=30, choices=VERB_CHOICES)
data = models.JSONField(default=dict)
timestamp = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ["timestamp"]
def to_prose(self):
"""Return a human-readable action description (actor rendered separately in template)."""
d = self.data
if self.verb == self.SLOT_FILLED:
_token_names = {
"coin": "Coin-on-a-String", "Free": "Free Token",
"tithe": "Tithe Token", "pass": "Backstage Pass", "carte": "Carte Blanche",
}
code = d.get("token_type", "token")
token = d.get("token_display") or _token_names.get(code, code)
days = d.get("renewal_days", 7)
slot = d.get("slot_number", "?")
return f"deposits a {token} for slot {slot} (expires in {days} days)."
if self.verb == self.SLOT_RESERVED:
return "reserves a seat"
if self.verb == self.SLOT_RETURNED:
return "withdraws from the gate"
if self.verb == self.SLOT_RELEASED:
return f"releases slot {d.get('slot_number', '?')}"
if self.verb == self.ROOM_CREATED:
return "opens this room"
if self.verb == self.INVITE_SENT:
return "sends an invitation"
if self.verb == self.ROLE_SELECT_STARTED:
return "Role selection begins"
if self.verb == self.ROLE_SELECTED:
_role_names = {
"PC": "Player", "BC": "Builder", "SC": "Shepherd",
"AC": "Alchemist", "NC": "Narrator", "EC": "Economist",
}
code = d.get("role", "?")
role = d.get("role_display") or _role_names.get(code, code)
return f"elects to start as the {role}, and will enjoy affinity with this Role for the remainder of the game."
if self.verb == self.ROLES_REVEALED:
return "All roles assigned"
return self.verb
def to_activity(self, base_url):
"""Serialise this event as an AS2 Activity dict, or None if unsupported."""
if not self.actor or not self.actor.username:
return None
actor_url = f"{base_url}/ap/users/{self.actor.username}/"
room_url = f"{base_url}/gameboard/room/{self.room_id}/"
if self.verb == self.SLOT_FILLED:
return {
"type": "earthman:JoinGate",
"actor": actor_url,
"object": room_url,
"summary": self.to_prose(),
}
if self.verb == self.ROLE_SELECTED:
return {
"type": "earthman:SelectRole",
"actor": actor_url,
"object": room_url,
"summary": self.to_prose(),
}
if self.verb == self.ROOM_CREATED:
return {
"type": "Create",
"actor": actor_url,
"object": room_url,
"summary": self.to_prose(),
}
return None
def __str__(self):
actor = self.actor.email if self.actor else "system"
return f"[{self.timestamp:%Y-%m-%d %H:%M}] {actor}{self.verb}"
class ScrollPosition(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE,
related_name="scroll_positions",
)
room = models.ForeignKey(
"epic.Room", on_delete=models.CASCADE,
related_name="scroll_positions",
)
position = models.PositiveIntegerField(default=0)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
unique_together = [("user", "room")]
def __str__(self):
return f"{self.user.email} @ {self.room.name}: {self.position}px"
def record(room, verb, actor=None, **data):
"""Record a game event in the drama log."""
return GameEvent.objects.create(room=room, actor=actor, verb=verb, data=data)

View File

View File

@@ -0,0 +1,73 @@
from django.test import TestCase
from django.db import IntegrityError
from apps.drama.models import GameEvent, ScrollPosition, record
from apps.epic.models import Room
from apps.lyric.models import User
class GameEventModelTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="actor@test.io")
self.room = Room.objects.create(name="Test Room", owner=self.user)
def test_record_creates_game_event(self):
event = record(self.room, GameEvent.SLOT_FILLED, actor=self.user, slot_number=1, token_type="tithe")
self.assertEqual(GameEvent.objects.count(), 1)
self.assertEqual(event.room, self.room)
self.assertEqual(event.actor, self.user)
self.assertEqual(event.verb, GameEvent.SLOT_FILLED)
self.assertEqual(event.data, {"slot_number": 1, "token_type": "tithe"})
def test_record_without_actor(self):
event = record(self.room, GameEvent.ROOM_CREATED)
self.assertIsNone(event.actor)
self.assertEqual(event.verb, GameEvent.ROOM_CREATED)
def test_events_ordered_by_timestamp(self):
record(self.room, GameEvent.ROOM_CREATED)
record(self.room, GameEvent.SLOT_RESERVED, actor=self.user)
record(self.room, GameEvent.SLOT_FILLED, actor=self.user)
verbs = list(GameEvent.objects.values_list("verb", flat=True))
self.assertEqual(verbs, [
GameEvent.ROOM_CREATED,
GameEvent.SLOT_RESERVED,
GameEvent.SLOT_FILLED,
])
def test_str_includes_actor_and_verb(self):
event = record(self.room, GameEvent.ROLE_SELECTED, actor=self.user, role="PC")
self.assertIn("actor@test.io", str(event))
self.assertIn(GameEvent.ROLE_SELECTED, str(event))
def test_str_without_actor_shows_system(self):
event = record(self.room, GameEvent.ROLES_REVEALED)
self.assertIn("system", str(event))
class ScrollPositionModelTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="reader@test.io")
self.room = Room.objects.create(name="Test Room", owner=self.user)
def test_can_save_scroll_position(self):
sp = ScrollPosition.objects.create(user=self.user, room=self.room, position=150)
self.assertEqual(ScrollPosition.objects.count(), 1)
self.assertEqual(sp.position, 150)
def test_default_position_is_zero(self):
sp = ScrollPosition.objects.create(user=self.user, room=self.room)
self.assertEqual(sp.position, 0)
def test_unique_per_user_and_room(self):
ScrollPosition.objects.create(user=self.user, room=self.room, position=50)
with self.assertRaises(IntegrityError):
ScrollPosition.objects.create(user=self.user, room=self.room, position=100)
def test_upsert_updates_existing_position(self):
ScrollPosition.objects.create(user=self.user, room=self.room, position=50)
ScrollPosition.objects.update_or_create(
user=self.user, room=self.room,
defaults={"position": 200},
)
self.assertEqual(ScrollPosition.objects.get(user=self.user, room=self.room).position, 200)

View File

18
src/apps/epic/admin.py Normal file
View File

@@ -0,0 +1,18 @@
from django.contrib import admin
from .models import DeckVariant, TarotCard
@admin.register(DeckVariant)
class DeckVariantAdmin(admin.ModelAdmin):
list_display = ["name", "slug", "card_count", "is_default"]
prepopulated_fields = {"slug": ["name"]}
@admin.register(TarotCard)
class TarotCardAdmin(admin.ModelAdmin):
list_display = ["name", "deck_variant", "arcana", "suit", "number", "group", "slug"]
list_filter = ["deck_variant", "arcana", "suit"]
search_fields = ["name", "slug", "correspondence", "group"]
readonly_fields = ["slug", "correspondence", "group"]
ordering = ["deck_variant", "arcana", "suit", "number"]

5
src/apps/epic/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class EpicConfig(AppConfig):
name = 'apps.epic'

View File

@@ -0,0 +1,82 @@
from channels.db import database_sync_to_async
from channels.generic.websocket import AsyncJsonWebsocketConsumer
LEVITY_ROLES = {"PC", "NC", "SC"}
GRAVITY_ROLES = {"BC", "EC", "AC"}
class RoomConsumer(AsyncJsonWebsocketConsumer):
async def connect(self):
self.room_id = self.scope["url_route"]["kwargs"]["room_id"]
self.group_name = f"room_{self.room_id}"
await self.channel_layer.group_add(self.group_name, self.channel_name)
self.cursor_group = None
user = self.scope.get("user")
if user and user.is_authenticated:
seat = await self._get_seat(user)
if seat:
if seat.role in LEVITY_ROLES:
self.cursor_group = f"cursors_{self.room_id}_levity"
elif seat.role in GRAVITY_ROLES:
self.cursor_group = f"cursors_{self.room_id}_gravity"
if self.cursor_group:
await self.channel_layer.group_add(self.cursor_group, self.channel_name)
await self.accept()
async def disconnect(self, close_code):
await self.channel_layer.group_discard(self.group_name, self.channel_name)
if self.cursor_group:
await self.channel_layer.group_discard(self.cursor_group, self.channel_name)
async def receive_json(self, content):
msg_type = content.get("type")
if msg_type == "cursor_move" and self.cursor_group:
await self.channel_layer.group_send(
self.cursor_group,
{"type": "cursor_move", "x": content.get("x"), "y": content.get("y")},
)
elif msg_type == "sig_hover" and self.cursor_group:
await self.channel_layer.group_send(
self.cursor_group,
{
"type": "sig_hover",
"card_id": content.get("card_id"),
"role": content.get("role"),
"active": content.get("active"),
},
)
@database_sync_to_async
def _get_seat(self, user):
from apps.epic.models import TableSeat
return TableSeat.objects.filter(room_id=self.room_id, gamer=user).first()
async def gate_update(self, event):
await self.send_json(event)
async def role_select_start(self, event):
await self.send_json(event)
async def turn_changed(self, event):
await self.send_json(event)
async def all_roles_filled(self, event):
await self.send_json(event)
async def sig_select_started(self, event):
await self.send_json(event)
async def sig_selected(self, event):
await self.send_json(event)
async def sig_hover(self, event):
await self.send_json(event)
async def sig_reserved(self, event):
await self.send_json(event)
async def cursor_move(self, event):
await self.send_json(event)

0
src/apps/epic/forms.py Normal file
View File

View File

@@ -0,0 +1,45 @@
# Generated by Django 6.0 on 2026-03-12 19:46
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Room',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(max_length=200)),
('visibility', models.CharField(choices=[('PRIVATE', 'Private'), ('PUBLIC', 'Public'), ('INVITE ONLY', 'Invite Only')], default='PRIVATE', max_length=20)),
('gate_status', models.CharField(choices=[('GATHERING', 'Gathering'), ('OPEN', 'Open'), ('RENEWAL_DUE', 'Renewal Due')], default='GATHERING', max_length=20)),
('renewal_period', models.DurationField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('board_state', models.JSONField(default=dict)),
('seed_count', models.IntegerField(default=12)),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owned_rooms', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='GateSlot',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slot_number', models.IntegerField()),
('status', models.CharField(choices=[('EMPTY', 'Empty'), ('RESERVED', 'Reserved'), ('FILLED', 'Filled')], default='EMPTY', max_length=10)),
('reserved_at', models.DateTimeField(blank=True, null=True)),
('filled_at', models.DateTimeField(blank=True, null=True)),
('funded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='funded_slots', to=settings.AUTH_USER_MODEL)),
('gamer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='gate_slots', to=settings.AUTH_USER_MODEL)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gate_slots', to='epic.room')),
],
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 6.0 on 2026-03-13 20:32
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='room',
name='renewal_period',
field=models.DurationField(blank=True, default=datetime.timedelta(days=7), null=True),
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 6.0 on 2026-03-13 22:19
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0002_alter_room_renewal_period'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='RoomInvite',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('invitee_email', models.EmailField(max_length=254)),
('status', models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('DECLINED', 'Declined')], default='PENDING', max_length=10)),
('created_at', models.DateTimeField(auto_now_add=True)),
('inviter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sent_invites', to=settings.AUTH_USER_MODEL)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invites', to='epic.room')),
],
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 6.0 on 2026-03-15 00:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0003_roominvite'),
]
operations = [
migrations.AlterField(
model_name='room',
name='gate_status',
field=models.CharField(choices=[('GATHERING', 'GATHERING GAMERS'), ('OPEN', 'Open'), ('RENEWAL_DUE', 'Renewal Due')], default='GATHERING', max_length=20),
),
]

View File

@@ -0,0 +1,21 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0004_alter_room_gate_status'),
]
operations = [
migrations.AddField(
model_name='gateslot',
name='debited_token_type',
field=models.CharField(max_length=8, null=True, blank=True),
),
migrations.AddField(
model_name='gateslot',
name='debited_token_expires_at',
field=models.DateTimeField(null=True, blank=True),
),
]

View File

@@ -0,0 +1,33 @@
# Generated by Django 6.0 on 2026-03-17 00:14
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0005_gateslot_debited_token_fields'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name='room',
name='table_status',
field=models.CharField(blank=True, choices=[('ROLE_SELECT', 'Role Select'), ('SIG_SELECT', 'Significator Select'), ('IN_GAME', 'In Game')], max_length=20, null=True),
),
migrations.CreateModel(
name='TableSeat',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slot_number', models.IntegerField()),
('role', models.CharField(blank=True, choices=[('PC', 'Player'), ('BC', 'Builder'), ('SC', 'Shepherd'), ('AC', 'Alchemist'), ('NC', 'Narrator'), ('EC', 'Economist')], max_length=2, null=True)),
('role_revealed', models.BooleanField(default=False)),
('seat_position', models.IntegerField(blank=True, null=True)),
('gamer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='table_seats', to=settings.AUTH_USER_MODEL)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='table_seats', to='epic.room')),
],
),
]

View File

@@ -0,0 +1,39 @@
# Generated by Django 6.0 on 2026-03-24 23:33
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0006_table_status_and_table_seat'),
]
operations = [
migrations.CreateModel(
name='TarotCard',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('arcana', models.CharField(choices=[('MAJOR', 'Major Arcana'), ('MINOR', 'Minor Arcana')], max_length=5)),
('suit', models.CharField(blank=True, choices=[('WANDS', 'Wands'), ('CUPS', 'Cups'), ('SWORDS', 'Swords'), ('PENTACLES', 'Pentacles')], max_length=10, null=True)),
('number', models.IntegerField()),
('slug', models.SlugField(unique=True)),
('keywords_upright', models.JSONField(default=list)),
('keywords_reversed', models.JSONField(default=list)),
],
options={
'ordering': ['arcana', 'suit', 'number'],
},
),
migrations.CreateModel(
name='TarotDeck',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('drawn_card_ids', models.JSONField(default=list)),
('created_at', models.DateTimeField(auto_now_add=True)),
('room', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='tarot_deck', to='epic.room')),
],
),
]

View File

@@ -0,0 +1,164 @@
from django.db import migrations
MAJOR_ARCANA = [
(0, "The Fool", "the-fool", ["beginnings", "spontaneity", "freedom"], ["recklessness", "naivety", "risk"]),
(1, "The Magician", "the-magician", ["willpower", "skill", "resourcefulness"], ["manipulation", "untapped potential", "deceit"]),
(2, "The High Priestess", "the-high-priestess", ["intuition", "mystery", "inner knowledge"], ["secrets", "disconnection", "withdrawal"]),
(3, "The Empress", "the-empress", ["fertility", "abundance", "nurturing"], ["dependence", "smothering", "creative block"]),
(4, "The Emperor", "the-emperor", ["authority", "structure", "stability"], ["rigidity", "domination", "inflexibility"]),
(5, "The Hierophant", "the-hierophant", ["tradition", "conformity", "institutions"], ["rebellion", "unconventionality", "challenge"]),
(6, "The Lovers", "the-lovers", ["love", "harmony", "choice"], ["disharmony", "imbalance", "misalignment"]),
(7, "The Chariot", "the-chariot", ["control", "willpower", "victory"], ["aggression", "lack of direction", "defeat"]),
(8, "Strength", "strength", ["courage", "patience", "compassion"], ["self-doubt", "weakness", "insecurity"]),
(9, "The Hermit", "the-hermit", ["introspection", "guidance", "solitude"], ["isolation", "loneliness", "withdrawal"]),
(10, "Wheel of Fortune", "wheel-of-fortune", ["change", "cycles", "fate"], ["bad luck", "resistance", "clinging to control"]),
(11, "Justice", "justice", ["fairness", "truth", "cause and effect"], ["injustice", "dishonesty", "avoidance"]),
(12, "The Hanged Man", "the-hanged-man", ["pause", "surrender", "new perspective"], ["stalling", "resistance", "indecision"]),
(13, "Death", "death", ["endings", "transition", "transformation"], ["fear of change", "stagnation", "resistance"]),
(14, "Temperance", "temperance", ["balance", "patience", "moderation"], ["imbalance", "excess", "lack of harmony"]),
(15, "The Devil", "the-devil", ["bondage", "materialism", "shadow self"], ["detachment", "freedom", "releasing control"]),
(16, "The Tower", "the-tower", ["sudden change", "upheaval", "revelation"], ["avoidance", "fear of change", "delaying disaster"]),
(17, "The Star", "the-star", ["hope", "renewal", "inspiration"], ["despair", "insecurity", "hopelessness"]),
(18, "The Moon", "the-moon", ["illusion", "fear", "the unconscious"], ["confusion", "misinterpretation", "clarity"]),
(19, "The Sun", "the-sun", ["positivity", "success", "vitality"], ["negativity", "depression", "sadness"]),
(20, "Judgement", "judgement", ["reflection", "reckoning", "absolution"], ["self-doubt", "lack of self-awareness", "loathing"]),
(21, "The World", "the-world", ["completion", "integration", "accomplishment"], ["incompletion", "no closure", "shortcuts"]),
]
MINOR_SUITS = [
("WANDS", "wands"),
("CUPS", "cups"),
("SWORDS", "swords"),
("PENTACLES", "pentacles"),
]
MINOR_NAMES = [
(1, "Ace", "ace"),
(2, "Two", "two"),
(3, "Three", "three"),
(4, "Four", "four"),
(5, "Five", "five"),
(6, "Six", "six"),
(7, "Seven", "seven"),
(8, "Eight", "eight"),
(9, "Nine", "nine"),
(10, "Ten", "ten"),
(11, "Page", "page"),
(12, "Knight", "knight"),
(13, "Queen", "queen"),
(14, "King", "king"),
]
# Keywords: [suit][number-1] → (upright_list, reversed_list)
MINOR_KEYWORDS = {
"WANDS": [
(["inspiration", "new venture", "spark"], ["delays", "lack of motivation", "false start"]),
(["planning", "progress", "decisions"], ["impatience", "lack of planning", "hesitation"]),
(["expansion", "foresight", "enterprise"], ["obstacles", "lack of foresight", "delays"]),
(["celebration", "harmony", "homecoming"], ["lack of support", "transience", "home conflicts"]),
(["conflict", "competition", "tension"], ["avoiding conflict", "compromise", "truce"]),
(["victory", "recognition", "progress"], ["excess pride", "lack of recognition", "fall"]),
(["challenge", "courage", "competition"], ["anxiety", "giving up", "overwhelmed"]),
(["rapid action", "adventure", "change"], ["haste", "scattered energy", "delays"]),
(["resilience", "persistence", "last stand"], ["exhaustion", "giving up", "surrender"]),
(["completion", "celebration", "travel"], ["burdens", "oppression", "carrying too much"]),
(["exploration", "enthusiasm", "adventure"], ["hasty decisions", "scattered energy", "immaturity"]),
(["energy", "passion", "adventure"], ["scattered energy", "frustration", "aggression"]),
(["confidence", "independence", "courage"], ["selfishness", "jealousy", "insecurity"]),
(["big picture", "leadership", "vision"], ["impulsiveness", "haste", "overconfidence"]),
],
"CUPS": [
(["new feelings", "intuition", "opportunity"], ["blocked creativity", "emptiness", "hesitation"]),
(["partnership", "unity", "celebration"], ["imbalance", "broken bonds", "misalignment"]),
(["creativity", "community", "abundance"], ["independence", "isolation", "looking inward"]),
(["contemplation", "apathy", "reevaluation"], ["withdrawal", "boredom", "seeking motivation"]),
(["loss", "grief", "disappointment"], ["acceptance", "moving on", "forgiveness"]),
(["nostalgia", "reunion", "joy"], ["living in the past", "naivety", "unrealistic"]),
(["illusion", "fantasy", "wishful thinking"], ["alignment", "clarity", "sobriety"]),
(["disappointment", "abandonment", "walking away"], ["hopelessness", "aimlessness", "stagnation"]),
(["contentment", "fulfilment", "satisfaction"], ["inner happiness", "materialism", "indulgence"]),
(["divine love", "bliss", "fulfilment"], ["inner happiness", "alignment", "personal values"]),
(["sensitivity", "creativity", "intuition"], ["insecurity", "emotional immaturity", "creative blocks"]),
(["compassion", "romanticism", "diplomacy"], ["moodiness", "emotional manipulation", "deception"]),
(["compassion", "empathy", "nurturing"], ["emotional insecurity", "over-giving", "neglect"]),
(["emotional maturity", "diplomacy", "wisdom"], ["manipulation", "moodiness", "coldness"]),
],
"SWORDS": [
(["raw power", "breakthrough", "clarity"], ["confusion", "brutality", "mental chaos"]),
(["difficult choices", "stalemate", "truce"], ["indecision", "lies", "confusion"]),
(["heartbreak", "sorrow", "grief"], ["recovery", "forgiveness", "moving on"]),
(["rest", "restoration", "retreat"], ["restlessness", "burnout", "illness"]),
(["defeat", "change", "transition"], ["resistance to change", "inability to move"]),
(["victory", "success", "ambition"], ["an eye for an eye", "dishonour", "manipulation"]),
(["deception", "trickery", "tactics"], ["imposter syndrome", "coming clean", "rethinking"]),
(["restriction", "isolation", "imprisonment"], ["self-limiting beliefs", "inner critic", "opening up"]),
(["anxiety", "worry", "fear"], ["recovery from anxiety", "inner turmoil", "secrets"]),
(["ruin", "painful endings", "loss"], ["recovery", "regeneration", "resisting an end"]),
(["new ideas", "mental agility", "curiosity"], ["manipulation", "all talk no action", "ruthlessness"]),
(["action", "impulsiveness", "ambition"], ["no direction", "disregard for consequences"]),
(["clarity", "directness", "structure"], ["coldness", "cruelty", "manipulation"]),
(["mental clarity", "truth", "authority"], ["abuse of power", "manipulation", "coldness"]),
],
"PENTACLES": [
(["opportunity", "new venture", "manifestation"], ["lost opportunity", "lack of planning", "scarcity"]),
(["juggling resources", "flexibility", "fun"], ["imbalance", "disorganisation", "overwhelm"]),
(["teamwork", "building", "apprenticeship"], ["lack of teamwork", "disharmony", "misalignment"]),
(["stability", "security", "conservation"], ["greed", "stinginess", "possessiveness"]),
(["isolation", "insecurity", "worry"], ["recovery from loss", "overcoming hardship"]),
(["generosity", "charity", "community"], ["strings attached", "power dynamics", "inequality"]),
(["hard work", "perseverance", "diligence"], ["lack of reward", "laziness", "low quality"]),
(["apprenticeship", "education", "skill"], ["perfectionism", "misdirected activity", "misuse"]),
(["abundance", "luxury", "self-sufficiency"], ["overindulgence", "superficiality", "materialism"]),
(["wealth", "financial security", "achievement"], ["financial failure", "greed", "lost success"]),
(["ambition", "diligence", "management"], ["underhandedness", "greediness", "unethical"]),
(["hard work", "productivity", "routine"], ["laziness", "obsession with work", "burnout"]),
(["nurturing", "practical", "abundance"], ["financial dependence", "smothering", "insecurity"]),
(["abundance", "prosperity", "security"], ["greed", "indulgence", "sensual obsession"]),
],
}
def seed_tarot_cards(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
# Major Arcana
for number, name, slug, upright, reversed_ in MAJOR_ARCANA:
TarotCard.objects.create(
name=name,
arcana="MAJOR",
suit=None,
number=number,
slug=slug,
keywords_upright=upright,
keywords_reversed=reversed_,
)
# Minor Arcana
for suit_code, suit_slug in MINOR_SUITS:
for number, rank_name, rank_slug in MINOR_NAMES:
upright, reversed_ = MINOR_KEYWORDS[suit_code][number - 1]
TarotCard.objects.create(
name=f"{rank_name} of {suit_code.capitalize()}",
arcana="MINOR",
suit=suit_code,
number=number,
slug=f"{rank_slug}-of-{suit_slug}",
keywords_upright=upright,
keywords_reversed=reversed_,
)
def unseed_tarot_cards(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
TarotCard.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
("epic", "0007_tarotcard_tarotdeck"),
]
operations = [
migrations.RunPython(seed_tarot_cards, reverse_code=unseed_tarot_cards),
]

View File

@@ -0,0 +1,68 @@
# Generated by Django 6.0 on 2026-03-25 00:48
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('epic', '0008_seed_tarot_cards'),
]
operations = [
migrations.CreateModel(
name='DeckVariant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('slug', models.SlugField(unique=True)),
('card_count', models.IntegerField()),
('description', models.TextField(blank=True)),
('is_default', models.BooleanField(default=False)),
],
),
migrations.AlterModelOptions(
name='tarotcard',
options={'ordering': ['deck_variant', 'arcana', 'suit', 'number']},
),
migrations.AddField(
model_name='tarotcard',
name='correspondence',
field=models.CharField(blank=True, max_length=200),
),
migrations.AddField(
model_name='tarotcard',
name='group',
field=models.CharField(blank=True, max_length=100),
),
migrations.AlterField(
model_name='tarotcard',
name='name',
field=models.CharField(max_length=200),
),
migrations.AlterField(
model_name='tarotcard',
name='slug',
field=models.SlugField(max_length=120),
),
migrations.AlterField(
model_name='tarotcard',
name='suit',
field=models.CharField(blank=True, choices=[('WANDS', 'Wands'), ('CUPS', 'Cups'), ('SWORDS', 'Swords'), ('PENTACLES', 'Pentacles'), ('COINS', 'Coins')], max_length=10, null=True),
),
migrations.AddField(
model_name='tarotcard',
name='deck_variant',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='cards', to='epic.deckvariant'),
),
migrations.AddField(
model_name='tarotdeck',
name='deck_variant',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='active_decks', to='epic.deckvariant'),
),
migrations.AlterUniqueTogether(
name='tarotcard',
unique_together={('deck_variant', 'slug')},
),
]

View File

@@ -0,0 +1,202 @@
"""
Data migration:
1. Create DeckVariant records (Fiorentine Minchiate + Earthman).
2. Backfill the 78 existing TarotCards → Fiorentine Minchiate.
3. Seed all 108 Earthman cards (52 major + 56 minor).
"""
from django.db import migrations
# ── Earthman Major Arcana (52 cards, numbers 051) ──────────────────────────
# (name, slug, group, correspondence)
EARTHMAN_MAJOR = [
# ── The Schiz ──────────────────────────────────────────────────────────
(0, "The Schiz", "the-schiz", "", "The Fool / Il Matto"),
# ── The Popes ──────────────────────────────────────────────────────────
(1, "Pope I: President", "pope-i-president", "The Popes", "The Magician / Il Bagatto"),
(2, "Pope II: Tsar", "pope-ii-tsar", "The Popes", "The Popess / La Papessa"),
(3, "Pope III: Chairman", "pope-iii-chairman", "The Popes", "The Empress / L'Imperatrice"),
(4, "Pope IV: Emperor", "pope-iv-emperor", "The Popes", "The Emperor / L'Imperatore"),
(5, "Pope V: Chancellor", "pope-v-chancellor", "The Popes", "The Pope / Il Papa"),
# ── The Virtues, Implicit (cardinal / acquired) ────────────────────────
(6, "Virtue VI: Controlled Folly", "virtue-vi-controlled-folly", "The Virtues, Implicit", "Fortitude / La Fortezza"),
(7, "Virtue VII: Not-Doing", "virtue-vii-not-doing", "The Virtues, Implicit", "Justice / La Giustizia"),
(8, "Virtue VIII: Losing Self-Importance","virtue-viii-losing-self-importance","The Virtues, Implicit", "Temperance / La Temperanza"),
(9, "Virtue IX: Erasing Personal History","virtue-ix-erasing-personal-history","The Virtues, Implicit", "Prudence / La Prudenza"),
# ── Wheel ──────────────────────────────────────────────────────────────
(10, "Wheel of Fortune", "wheel-of-fortune-em", "", "La Ruota della Fortuna"),
# ── Solo cards ─────────────────────────────────────────────────────────
(11, "The Junkboat", "the-junkboat", "", "The Chariot / Il Carro"),
(12, "The Junkman", "the-junkman", "", "The Hanged Man / L'Appeso"),
(13, "Death", "death-em", "", "La Morte"),
(14, "The Traitor", "the-traitor", "", "The Devil / Il Diavolo"),
(15, "Disco Inferno", "disco-inferno", "", "The Tower / La Torre"),
(16, "Torre Terrestre", "torre-terrestre", "", "Purgatorio"),
(17, "Fantasia Celestia", "fantasia-celestia", "", "Paradiso"),
# ── The Virtues, Explicit (theological / infused) ─────────────────────
(18, "Virtue XVIII: Stalking", "virtue-xviii-stalking", "The Virtues, Explicit", "Love / Charity / La Carità"),
(19, "Virtue XIX: Intent", "virtue-xix-intent", "The Virtues, Explicit", "Hope / La Speranza"),
(20, "Virtue XX: Dreaming", "virtue-xx-dreaming", "The Virtues, Explicit", "Faith / La Fede"),
# ── The Elements, Classical ────────────────────────────────────────────
(21, "Element XXI: Fire", "element-xxi-fire", "The Elements, Classical", "Ardor [Ar]"),
(22, "Element XXII: Earth", "element-xxii-earth", "The Elements, Classical", "Ossum [Om]"),
(23, "Element XXIII: Air", "element-xxiii-air", "The Elements, Classical", "Pneuma [Pn]"),
(24, "Element XXIV: Water", "element-xxiv-water", "The Elements, Classical", "Humor [Hm]"),
# ── The Zodiac ─────────────────────────────────────────────────────────
(25, "Zodiac XXV: Aries", "zodiac-xxv-aries", "The Zodiac", "The Ram"),
(26, "Zodiac XXVI: Taurus", "zodiac-xxvi-taurus", "The Zodiac", "The Bull"),
(27, "Zodiac XXVII: Gemini", "zodiac-xxvii-gemini", "The Zodiac", "The Twins"),
(28, "Zodiac XXVIII: Cancer", "zodiac-xxviii-cancer", "The Zodiac", "The Crab"),
(29, "Zodiac XXIX: Leo", "zodiac-xxix-leo", "The Zodiac", "The Lion"),
(30, "Zodiac XXX: Virgo", "zodiac-xxx-virgo", "The Zodiac", "The Maiden"),
(31, "Zodiac XXXI: Libra", "zodiac-xxxi-libra", "The Zodiac", "The Scales"),
(32, "Zodiac XXXII: Scorpio", "zodiac-xxxii-scorpio", "The Zodiac", "The Scorpion"),
(33, "Zodiac XXXIII: Sagittarius", "zodiac-xxxiii-sagittarius", "The Zodiac", "The Archer"),
(34, "Zodiac XXXIV: Capricorn", "zodiac-xxxiv-capricorn", "The Zodiac", "The Sea-Goat"),
(35, "Zodiac XXXV: Aquarius", "zodiac-xxxv-aquarius", "The Zodiac", "The Water-Bearer"),
(36, "Zodiac XXXVI: Pisces", "zodiac-xxxvi-pisces", "The Zodiac", "The Fish"),
# ── The Elements, Absolute ─────────────────────────────────────────────
(37, "Element XXXVII: Time", "element-xxxvii-time", "The Elements, Absolute", "Tempo [Tp]"),
(38, "Element XXXVIII: Space", "element-xxxviii-space", "The Elements, Absolute", "Nexus [Nx]"),
# ── The Wanderers ──────────────────────────────────────────────────────
(39, "Wanderer XXXIX: The Polestar", "wanderer-xxxix-polestar", "The Wanderers", "The Star / Le Stelle"),
(40, "Wanderer XL: The Antichthon", "wanderer-xl-antichthon", "The Wanderers", "The Moon / La Luna"),
(41, "Wanderer XLI: The Corestar", "wanderer-xli-corestar", "The Wanderers", "The Sun / Il Sole"),
(42, "Wanderer XLII: Mercury", "wanderer-xlii-mercury", "The Wanderers", "Mercurio"),
(43, "Wanderer XLIII: Venus", "wanderer-xliii-venus", "The Wanderers", "Venere"),
(44, "Wanderer XLIV: Mars", "wanderer-xliv-mars", "The Wanderers", "Marte"),
(45, "Wanderer XLV: Jupiter", "wanderer-xlv-jupiter", "The Wanderers", "Giove"),
(46, "Wanderer XLVI: Saturn", "wanderer-xlvi-saturn", "The Wanderers", "Saturno"),
(47, "Wanderer XLVII: Uranus", "wanderer-xlvii-uranus", "The Wanderers", "Urano"),
(48, "Wanderer XLVIII: Neptune", "wanderer-xlviii-neptune", "The Wanderers", "Nettuno"),
(49, "Wanderer XLIX: The King & Queen of Hades", "wanderer-xlix-king-queen-hades", "The Wanderers", "The Binary / Plutone-Proserpina"),
# ── Finale ─────────────────────────────────────────────────────────────
(50, "The Eagle", "the-eagle", "", "Judgement / L'Angelo"),
(51, "Divine Calculus", "divine-calculus", "", "The World / Il Mondo"),
]
# ── Earthman Minor Arcana ────────────────────────────────────────────────────
# 4 suits × 14 cards. Suits: WANDS / CUPS / SWORDS / COINS
# Court cards: Jack (11) / Cavalier (12) / Queen (13) / King (14)
EARTHMAN_SUITS = [
("WANDS", "wands", "Ardor [Ar] — Fire"),
("CUPS", "cups", "Humor [Hm] — Water"),
("SWORDS","swords","Pneuma [Pn] — Air"),
("COINS", "coins", "Ossum [Om] — Stone"),
]
EARTHMAN_RANKS = [
(1, "Ace", "ace"),
(2, "2", "two"),
(3, "3", "three"),
(4, "4", "four"),
(5, "5", "five"),
(6, "6", "six"),
(7, "7", "seven"),
(8, "8", "eight"),
(9, "9", "nine"),
(10, "10", "ten"),
(11, "Jack", "jack"),
(12, "Cavalier", "cavalier"),
(13, "Queen", "queen"),
(14, "King", "king"),
]
def forward(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
# ── 1. Create DeckVariant records ────────────────────────────────────
fiorentine = DeckVariant.objects.create(
name="Fiorentine Minchiate",
slug="fiorentine-minchiate",
card_count=78,
description="Standard 78-card Minchiate deck. Alt / lite play mode.",
is_default=False,
)
earthman = DeckVariant.objects.create(
name="Earthman Deck",
slug="earthman",
card_count=108,
description=(
"Primary 108-card Earthman deck. "
"52 Major Arcana (The Schiz through Divine Calculus) "
"+ 56 Minor Arcana across Wands, Cups, Swords, Coins."
),
is_default=True,
)
# ── 2. Backfill existing 78 Fiorentine cards ─────────────────────────
TarotCard.objects.filter(deck_variant__isnull=True).update(
deck_variant=fiorentine
)
# ── 3. Seed Earthman Major Arcana ────────────────────────────────────
for number, name, slug, group, correspondence in EARTHMAN_MAJOR:
TarotCard.objects.create(
deck_variant=earthman,
name=name,
arcana="MAJOR",
suit=None,
number=number,
slug=slug,
group=group,
correspondence=correspondence,
keywords_upright=[],
keywords_reversed=[],
)
# ── 4. Seed Earthman Minor Arcana ────────────────────────────────────
for suit_code, suit_slug, _element in EARTHMAN_SUITS:
for number, rank_name, rank_slug in EARTHMAN_RANKS:
name = f"{rank_name} of {suit_code.capitalize()}"
slug = f"{rank_slug}-of-{suit_slug}-em"
TarotCard.objects.create(
deck_variant=earthman,
name=name,
arcana="MINOR",
suit=suit_code,
number=number,
slug=slug,
group="",
correspondence="",
keywords_upright=[],
keywords_reversed=[],
)
def reverse(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
# Remove Earthman cards and clear FK from Fiorentine cards
earthman = DeckVariant.objects.filter(slug="earthman").first()
if earthman:
TarotCard.objects.filter(deck_variant=earthman).delete()
fiorentine = DeckVariant.objects.filter(slug="fiorentine-minchiate").first()
if fiorentine:
TarotCard.objects.filter(deck_variant=fiorentine).update(deck_variant=None)
DeckVariant.objects.filter(slug__in=["earthman", "fiorentine-minchiate"]).delete()
class Migration(migrations.Migration):
dependencies = [
("epic", "0009_deckvariant_alter_tarotcard_options_and_more"),
]
operations = [
migrations.RunPython(forward, reverse_code=reverse),
]

View File

@@ -0,0 +1,82 @@
"""
Data migration: rename Earthman court cards at positions 11 and 12.
Old naming (from 0010): Jack (11) / Cavalier (12)
New naming: Maid (11) / Jack (12)
Must rename 11 → Maid first so the "jack-of-*-em" slugs are free
before the 12s claim them.
"""
from django.db import migrations
SUITS = ["Wands", "Cups", "Swords", "Coins"]
def rename_court_cards(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
# Step 1: Jack (11) → Maid — frees up jack-of-*-em slugs
for suit in SUITS:
suit_slug = suit.lower()
TarotCard.objects.filter(
deck_variant=earthman, number=11, slug=f"jack-of-{suit_slug}-em"
).update(
name=f"Maid of {suit}",
slug=f"maid-of-{suit_slug}-em",
)
# Step 2: Cavalier (12) → Jack — takes the now-free jack-of-*-em slugs
for suit in SUITS:
suit_slug = suit.lower()
TarotCard.objects.filter(
deck_variant=earthman, number=12, slug=f"cavalier-of-{suit_slug}-em"
).update(
name=f"Jack of {suit}",
slug=f"jack-of-{suit_slug}-em",
)
def reverse_court_cards(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
# Step 1: Jack (12) → Cavalier — frees up jack-of-*-em slugs
for suit in SUITS:
suit_slug = suit.lower()
TarotCard.objects.filter(
deck_variant=earthman, number=12, slug=f"jack-of-{suit_slug}-em"
).update(
name=f"Cavalier of {suit}",
slug=f"cavalier-of-{suit_slug}-em",
)
# Step 2: Maid (11) → Jack
for suit in SUITS:
suit_slug = suit.lower()
TarotCard.objects.filter(
deck_variant=earthman, number=11, slug=f"maid-of-{suit_slug}-em"
).update(
name=f"Jack of {suit}",
slug=f"jack-of-{suit_slug}-em",
)
class Migration(migrations.Migration):
dependencies = [
("epic", "0010_seed_deck_variants_and_earthman"),
]
operations = [
migrations.RunPython(rename_court_cards, reverse_code=reverse_court_cards),
]

View File

@@ -0,0 +1,162 @@
"""
Data migration:
1. Rename grouped Earthman major arcana to use group-relative ordinals
(e.g. "Virtue VI: Controlled Folly""Implicit Virtue 1: Controlled Folly").
2. Spell out Earthman minor arcana pip names 210
(e.g. "2 of Wands""Two of Wands").
Corner ranks (Roman numerals of absolute card number) are a property on the model
and are unchanged — this only affects the stored name / slug fields.
"""
from django.db import migrations
# ── Major arcana: (new_name, new_slug) keyed by card number ─────────────────
MAJOR_RENAMES = {
# Implicit Virtues (cards 69)
6: ("Implicit Virtue 1: Controlled Folly", "implicit-virtue-1-controlled-folly"),
7: ("Implicit Virtue 2: Not-Doing", "implicit-virtue-2-not-doing"),
8: ("Implicit Virtue 3: Losing Self-Importance", "implicit-virtue-3-losing-self-importance"),
9: ("Implicit Virtue 4: Erasing Personal History", "implicit-virtue-4-erasing-personal-history"),
# Explicit Virtues (cards 1820)
18: ("Explicit Virtue 1: Stalking", "explicit-virtue-1-stalking"),
19: ("Explicit Virtue 2: Intent", "explicit-virtue-2-intent"),
20: ("Explicit Virtue 3: Dreaming", "explicit-virtue-3-dreaming"),
# Classical Elements (cards 2124)
21: ("Classical Element 1: Fire", "classical-element-1-fire"),
22: ("Classical Element 2: Earth", "classical-element-2-earth"),
23: ("Classical Element 3: Air", "classical-element-3-air"),
24: ("Classical Element 4: Water", "classical-element-4-water"),
# Zodiac (cards 2536)
25: ("Zodiac 1: Aries", "zodiac-1-aries"),
26: ("Zodiac 2: Taurus", "zodiac-2-taurus"),
27: ("Zodiac 3: Gemini", "zodiac-3-gemini"),
28: ("Zodiac 4: Cancer", "zodiac-4-cancer"),
29: ("Zodiac 5: Leo", "zodiac-5-leo"),
30: ("Zodiac 6: Virgo", "zodiac-6-virgo"),
31: ("Zodiac 7: Libra", "zodiac-7-libra"),
32: ("Zodiac 8: Scorpio", "zodiac-8-scorpio"),
33: ("Zodiac 9: Sagittarius", "zodiac-9-sagittarius"),
34: ("Zodiac 10: Capricorn", "zodiac-10-capricorn"),
35: ("Zodiac 11: Aquarius", "zodiac-11-aquarius"),
36: ("Zodiac 12: Pisces", "zodiac-12-pisces"),
# Absolute Elements (cards 3738)
37: ("Absolute Element 1: Time", "absolute-element-1-time"),
38: ("Absolute Element 2: Space", "absolute-element-2-space"),
# Wanderers (cards 3949)
39: ("Wanderer 1: The Polestar", "wanderer-1-polestar"),
40: ("Wanderer 2: The Antichthon", "wanderer-2-antichthon"),
41: ("Wanderer 3: The Corestar", "wanderer-3-corestar"),
42: ("Wanderer 4: Mercury", "wanderer-4-mercury"),
43: ("Wanderer 5: Venus", "wanderer-5-venus"),
44: ("Wanderer 6: Mars", "wanderer-6-mars"),
45: ("Wanderer 7: Jupiter", "wanderer-7-jupiter"),
46: ("Wanderer 8: Saturn", "wanderer-8-saturn"),
47: ("Wanderer 9: Uranus", "wanderer-9-uranus"),
48: ("Wanderer 10: Neptune", "wanderer-10-neptune"),
49: ("Wanderer 11: The King & Queen of Hades", "wanderer-11-king-queen-hades"),
}
# Original (name, slug) pairs for reversal
MAJOR_ORIGINALS = {
6: ("Virtue VI: Controlled Folly", "virtue-vi-controlled-folly"),
7: ("Virtue VII: Not-Doing", "virtue-vii-not-doing"),
8: ("Virtue VIII: Losing Self-Importance", "virtue-viii-losing-self-importance"),
9: ("Virtue IX: Erasing Personal History", "virtue-ix-erasing-personal-history"),
18: ("Virtue XVIII: Stalking", "virtue-xviii-stalking"),
19: ("Virtue XIX: Intent", "virtue-xix-intent"),
20: ("Virtue XX: Dreaming", "virtue-xx-dreaming"),
21: ("Element XXI: Fire", "element-xxi-fire"),
22: ("Element XXII: Earth", "element-xxii-earth"),
23: ("Element XXIII: Air", "element-xxiii-air"),
24: ("Element XXIV: Water", "element-xxiv-water"),
25: ("Zodiac XXV: Aries", "zodiac-xxv-aries"),
26: ("Zodiac XXVI: Taurus", "zodiac-xxvi-taurus"),
27: ("Zodiac XXVII: Gemini", "zodiac-xxvii-gemini"),
28: ("Zodiac XXVIII: Cancer", "zodiac-xxviii-cancer"),
29: ("Zodiac XXIX: Leo", "zodiac-xxix-leo"),
30: ("Zodiac XXX: Virgo", "zodiac-xxx-virgo"),
31: ("Zodiac XXXI: Libra", "zodiac-xxxi-libra"),
32: ("Zodiac XXXII: Scorpio", "zodiac-xxxii-scorpio"),
33: ("Zodiac XXXIII: Sagittarius", "zodiac-xxxiii-sagittarius"),
34: ("Zodiac XXXIV: Capricorn", "zodiac-xxxiv-capricorn"),
35: ("Zodiac XXXV: Aquarius", "zodiac-xxxv-aquarius"),
36: ("Zodiac XXXVI: Pisces", "zodiac-xxxvi-pisces"),
37: ("Element XXXVII: Time", "element-xxxvii-time"),
38: ("Element XXXVIII: Space", "element-xxxviii-space"),
39: ("Wanderer XXXIX: The Polestar", "wanderer-xxxix-polestar"),
40: ("Wanderer XL: The Antichthon", "wanderer-xl-antichthon"),
41: ("Wanderer XLI: The Corestar", "wanderer-xli-corestar"),
42: ("Wanderer XLII: Mercury", "wanderer-xlii-mercury"),
43: ("Wanderer XLIII: Venus", "wanderer-xliii-venus"),
44: ("Wanderer XLIV: Mars", "wanderer-xliv-mars"),
45: ("Wanderer XLV: Jupiter", "wanderer-xlv-jupiter"),
46: ("Wanderer XLVI: Saturn", "wanderer-xlvi-saturn"),
47: ("Wanderer XLVII: Uranus", "wanderer-xlvii-uranus"),
48: ("Wanderer XLVIII: Neptune", "wanderer-xlviii-neptune"),
49: ("Wanderer XLIX: The King & Queen of Hades", "wanderer-xlix-king-queen-hades"),
}
# Pip number → spelled-out word (slugs already use the word form, only name changes)
PIP_SPELLINGS = {
2: "Two", 3: "Three", 4: "Four", 5: "Five",
6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", 10: "Ten",
}
SUITS = ["WANDS", "CUPS", "SWORDS", "COINS"]
def rename_forward(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
# 1. Rename grouped major arcana to group-relative ordinals
for number, (new_name, new_slug) in MAJOR_RENAMES.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=new_name, slug=new_slug)
# 2. Spell out pip names 210
for number, word in PIP_SPELLINGS.items():
for suit in SUITS:
TarotCard.objects.filter(
deck_variant=earthman, arcana="MINOR", suit=suit, number=number
).update(name=f"{word} of {suit.capitalize()}")
def rename_reverse(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
# 1. Restore original major arcana names
for number, (old_name, old_slug) in MAJOR_ORIGINALS.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=old_name, slug=old_slug)
# 2. Restore numeric pip names (slugs unchanged)
for number, _word in PIP_SPELLINGS.items():
for suit in SUITS:
TarotCard.objects.filter(
deck_variant=earthman, arcana="MINOR", suit=suit, number=number
).update(name=f"{number} of {suit.capitalize()}")
class Migration(migrations.Migration):
dependencies = [
("epic", "0011_rename_earthman_court_cards"),
]
operations = [
migrations.RunPython(rename_forward, reverse_code=rename_reverse),
]

View File

@@ -0,0 +1,55 @@
"""
Data migration: rename Earthman 4th-suit cards from COINS → PENTACLES.
Updates:
- suit field: "COINS""PENTACLES"
- name: "X of Coins""X of Pentacles"
- slug: "x-of-coins-em""x-of-pentacles-em"
"""
from django.db import migrations
def coins_to_pentacles(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
cards = TarotCard.objects.filter(deck_variant=earthman, suit="COINS")
for card in cards:
card.suit = "PENTACLES"
card.name = card.name.replace(" of Coins", " of Pentacles")
card.slug = card.slug.replace("-of-coins-em", "-of-pentacles-em")
card.save(update_fields=["suit", "name", "slug"])
def pentacles_to_coins(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
# Only reverse cards that came from Earthman (identified by -em slug suffix)
cards = TarotCard.objects.filter(
deck_variant=earthman, suit="PENTACLES", slug__endswith="-em"
)
for card in cards:
card.suit = "COINS"
card.name = card.name.replace(" of Pentacles", " of Coins")
card.slug = card.slug.replace("-of-pentacles-em", "-of-coins-em")
card.save(update_fields=["suit", "name", "slug"])
class Migration(migrations.Migration):
dependencies = [
("epic", "0012_rename_earthman_major_groups_and_pip_spellings"),
]
operations = [
migrations.RunPython(coins_to_pentacles, reverse_code=pentacles_to_coins),
]

View File

@@ -0,0 +1,65 @@
"""
Data migration: rename the five Pope cards to use Arabic group-relative ordinals,
matching the convention set for other grouped major arcana.
"Pope I: President""Pope 1: President"
"Pope II: Tsar""Pope 2: Tsar"
etc.
"""
from django.db import migrations
POPE_RENAMES = {
1: ("Pope 1: President", "pope-1-president"),
2: ("Pope 2: Tsar", "pope-2-tsar"),
3: ("Pope 3: Chairman", "pope-3-chairman"),
4: ("Pope 4: Emperor", "pope-4-emperor"),
5: ("Pope 5: Chancellor", "pope-5-chancellor"),
}
POPE_ORIGINALS = {
1: ("Pope I: President", "pope-i-president"),
2: ("Pope II: Tsar", "pope-ii-tsar"),
3: ("Pope III: Chairman", "pope-iii-chairman"),
4: ("Pope IV: Emperor", "pope-iv-emperor"),
5: ("Pope V: Chancellor", "pope-v-chancellor"),
}
def rename_forward(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
for number, (new_name, new_slug) in POPE_RENAMES.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=new_name, slug=new_slug)
def rename_reverse(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
for number, (old_name, old_slug) in POPE_ORIGINALS.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=old_name, slug=old_slug)
class Migration(migrations.Migration):
dependencies = [
("epic", "0013_earthman_coins_to_pentacles"),
]
operations = [
migrations.RunPython(rename_forward, reverse_code=rename_reverse),
]

View File

@@ -0,0 +1,42 @@
"""
Data migration: rename Earthman card 22 from "Classical Element 2: Earth"
to "Classical Element 2: Stone" (Stone = Ossum, the Earthman name for Earth).
"""
from django.db import migrations
def rename_forward(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=22
).update(name="Classical Element 2: Stone", slug="classical-element-2-stone")
def rename_reverse(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=22
).update(name="Classical Element 2: Earth", slug="classical-element-2-earth")
class Migration(migrations.Migration):
dependencies = [
("epic", "0014_rename_earthman_popes_arabic_ordinals"),
]
operations = [
migrations.RunPython(rename_forward, reverse_code=rename_reverse),
]

View File

@@ -0,0 +1,63 @@
"""
Data migration: reorder the five Pope cards.
New assignment (card number → title):
1 → Chancellor 2 → President 3 → Tsar 4 → Chairman 5 → Emperor
"""
from django.db import migrations
POPE_RENAMES = {
1: ("Pope 1: Chancellor", "pope-1-chancellor"),
2: ("Pope 2: President", "pope-2-president"),
3: ("Pope 3: Tsar", "pope-3-tsar"),
4: ("Pope 4: Chairman", "pope-4-chairman"),
5: ("Pope 5: Emperor", "pope-5-emperor"),
}
POPE_ORIGINALS = {
1: ("Pope 1: President", "pope-1-president"),
2: ("Pope 2: Tsar", "pope-2-tsar"),
3: ("Pope 3: Chairman", "pope-3-chairman"),
4: ("Pope 4: Emperor", "pope-4-emperor"),
5: ("Pope 5: Chancellor", "pope-5-chancellor"),
}
def rename_forward(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
for number, (new_name, new_slug) in POPE_RENAMES.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=new_name, slug=new_slug)
def rename_reverse(apps, schema_editor):
TarotCard = apps.get_model("epic", "TarotCard")
DeckVariant = apps.get_model("epic", "DeckVariant")
earthman = DeckVariant.objects.filter(slug="earthman").first()
if not earthman:
return
for number, (old_name, old_slug) in POPE_ORIGINALS.items():
TarotCard.objects.filter(
deck_variant=earthman, arcana="MAJOR", number=number
).update(name=old_name, slug=old_slug)
class Migration(migrations.Migration):
dependencies = [
("epic", "0015_rename_classical_element_earth_to_stone"),
]
operations = [
migrations.RunPython(rename_forward, reverse_code=rename_reverse),
]

Some files were not shown because too many files have changed in this diff Show More