Add player profile endpoints (GET + PATCH) — Phase 11a #89
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
forgejo_admin/basketball-api#89
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Lineage
plan-2026-03-08-tryout-prep→ Phase 11 → Phase 11aRepo
forgejo_admin/basketball-apiUser Story
As a player/parent, coach, or admin
I want API endpoints to view and update individual player profiles
So that the frontend can render a player profile page with role-based edit permissions
Context
Phase 11 adds player profile pages as the central entity in the westside app. The roster endpoints exist but only return flat lists — there's no way to GET a single player's full profile or PATCH their editable fields. The frontend needs these endpoints before the profile page can be built.
Permission model decided by Lucas:
Auth architecture: Keycloak OIDC JWT validation is already implemented (
auth.py).get_current_user()returns a User dataclass withsub,email,username,roles.require_role()factory checks role membership. Player ownership check: matchplayer.parent.emailagainstcurrent_user.email.Existing infrastructure:
POST /upload/photo(returnsphoto_url)player.teamwith coach info)_get_tenant_or_404in teams.py)File Targets
Files to create:
src/basketball_api/routes/players.py— New router with GET and PATCH endpointstests/test_players.py— Tests for both endpoints + permission scenariosFiles to modify:
src/basketball_api/main.py— Register the new players routerFiles NOT to touch:
src/basketball_api/routes/roster.py— Existing roster endpoints (don't break)src/basketball_api/routes/tryouts.py— Existing tryout endpointssrc/basketball_api/models.py— Player model already has all needed fieldssrc/basketball_api/auth.py— Auth middleware already worksAcceptance Criteria
GET /api/players/{player_id}returns full player profile including: name, height, position, graduating_class, current_school, target_schools, hometown, photo_url, division, tryout_number, subscription_status, team (name + coach name if assigned), parent info (name, email, phone)GET /api/players/{player_id}requires authentication (any role: admin, coach, or player)GET /api/players/{player_id}returns 404 for non-existent playerPATCH /api/players/{player_id}allows updating: height, position, graduating_class, current_school, target_schools, hometown, photo_urlPATCH /api/players/{player_id}with admin role can update any playerPATCH /api/players/{player_id}with player role can only update their own profile (parent email match). Returns 403 otherwise.PATCH /api/players/{player_id}with coach role returns 403 (read-only)PATCH /api/players/{player_id}returns the updated player profileTest Expectations
cd ~/basketball-api && python -m pytest tests/test_players.py -vConstraints
routes/teams.pyfor style referenceRosterResponse/PlayerInfopatterns)get_current_userandrequire_rolefromauth.pyplayer.parent.email == current_user.email(case-insensitive)/api/players— register inmain.pyplayer.team)player.parent)asyncroute handlers matching existing codebase patternChecklist
pytest tests/test_players.py -v)pytest tests/ -v)Related
project-westside-basketball— project this affects