feat: add player_id param to jersey/checkout for multi-player parents (#256) #261
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/basketball-api!261
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "256-player-id-jersey-checkout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add optional
player_idquery parameter to jersey and checkout endpoints so parents with multiple players can specify which child they are ordering for. When omitted, defaults toparent.players[0]for backwards compatibility. Returns 403 when aplayer_iddoes not belong to the authenticated parent.Changes
src/basketball_api/routes/jersey.py— Added_resolve_player()helper andplayer_id: int | None = Query(None)tojersey_player_infoandjersey_checkoutendpointssrc/basketball_api/routes/checkout.py— Added_resolve_player()helper andplayer_id: int | None = Query(None)tocreate_checkout_sessionendpoint; addedPlayerimporttests/test_jersey.py— Addedparent_with_two_playersfixture andTestPlayerIdPlayerInfo/TestPlayerIdJerseyCheckouttest classes (7 new tests)tests/test_checkout.py— Addedparent_with_two_playersfixture andTestPlayerIdCheckoutCreateSessiontest class (4 new tests)Test Plan
pytest tests/ -k "player_id or jersey or checkout"— 97 passedpytest tests/ -x -q— 700 passed, 0 failedruff formatandruff checkcleanReview Checklist
player_idis optional (None default) — backwards compatibleplayer.parent_id == parent.idvia list membership — no cross-parent accessparent.players[0]when player_id omittedRelated Notes
QA Review -- PR #261
Summary
Adds optional
player_idquery parameter to 3 endpoints (jersey/player-info,jersey/checkout,checkout/create-session) so multi-player parents can target a specific child. Defaults to first player when omitted. Returns 403 for cross-parent access.Findings
Correctness -- PASS
_resolve_playervalidates ownership by iteratingparent.players(loaded viajoinedload), no raw query bypass possibleplayer_id=Nonefalls through toparent.players[0]Security -- PASS
player_idvalue but not sensitive dataTest Coverage -- PASS
Scope -- PASS
Nits (non-blocking)
_resolve_player: Identical 16-line function in bothjersey.pyandcheckout.py. Could be extracted to a shared utility (e.g.,basketball_api/utils/player_resolve.py). Not a blocker -- the function is small and the modules are independent. Defer to a cleanup ticket if desired.VERDICT: APPROVED
400fecc745f5d680d9ba