feat: add admin schedule API endpoints for practices and events #236

Merged
forgejo_admin merged 1 commit from 233-schedule-api-endpoints into main 2026-03-28 23:18:40 +00:00

Summary

Adds 9 admin CRUD endpoints under /admin/schedule for managing practice schedules and events. All endpoints are tenant-scoped and admin-authenticated, with division/event_type filters and program label mapping (boys→Kings, girls→Queens) for frontend convenience.

Changes

  • src/basketball_api/routes/schedule.py — NEW file. Admin CRUD endpoints with inline Pydantic schemas: combined GET, practice list/create/update/delete, event list/create/update/delete.
  • src/basketball_api/main.py — Register schedule router at /admin/schedule.
  • tests/test_schedule.py — Added 25 endpoint tests covering happy paths, filters, tenant isolation, 404s, validation, and unauthenticated access (39 total with existing model tests).

Test Plan

  • pytest tests/test_schedule.py -v — 39 passed
  • pytest tests/ -v — 680 passed (full suite, no regressions)
  • ruff format + ruff check — clean

Review Checklist

  • All 9 endpoints implemented per acceptance criteria
  • Tenant scoping on all queries (read, update, delete)
  • Division filter on practices and events
  • event_type filter on events
  • is_active filter on practices
  • Program label mapping (boys→Kings, girls→Queens)
  • Proper HTTP status codes (201 create, 200 read/update, 204 delete)
  • 404 on non-existent IDs
  • Pydantic validation for required fields
  • Tenant isolation tests (can't access other tenant's data)
  • Unauthenticated access returns 401/403
  • ruff format + ruff check clean
  • No pal-e-docs notes affected.
  • Closes #233
  • Parent: #230 (schedule epic)
  • Depends on: #232 (data model, merged)
## Summary Adds 9 admin CRUD endpoints under `/admin/schedule` for managing practice schedules and events. All endpoints are tenant-scoped and admin-authenticated, with division/event_type filters and program label mapping (boys→Kings, girls→Queens) for frontend convenience. ## Changes - `src/basketball_api/routes/schedule.py` — NEW file. Admin CRUD endpoints with inline Pydantic schemas: combined GET, practice list/create/update/delete, event list/create/update/delete. - `src/basketball_api/main.py` — Register schedule router at `/admin/schedule`. - `tests/test_schedule.py` — Added 25 endpoint tests covering happy paths, filters, tenant isolation, 404s, validation, and unauthenticated access (39 total with existing model tests). ## Test Plan - `pytest tests/test_schedule.py -v` — 39 passed - `pytest tests/ -v` — 680 passed (full suite, no regressions) - `ruff format` + `ruff check` — clean ## Review Checklist - [x] All 9 endpoints implemented per acceptance criteria - [x] Tenant scoping on all queries (read, update, delete) - [x] Division filter on practices and events - [x] event_type filter on events - [x] is_active filter on practices - [x] Program label mapping (boys→Kings, girls→Queens) - [x] Proper HTTP status codes (201 create, 200 read/update, 204 delete) - [x] 404 on non-existent IDs - [x] Pydantic validation for required fields - [x] Tenant isolation tests (can't access other tenant's data) - [x] Unauthenticated access returns 401/403 - [x] ruff format + ruff check clean ## Related Notes - No pal-e-docs notes affected. ## Related - Closes #233 - Parent: #230 (schedule epic) - Depends on: #232 (data model, merged)
feat: add admin schedule API endpoints for practices and events
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
f875334c95
9 CRUD endpoints under /admin/schedule for managing practice schedules
and events, with tenant scoping, division/event_type filters, and
program label mapping (boys->Kings, girls->Queens).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

QA Review -- PR #236

Summary

9 admin CRUD endpoints for schedule management (practices + events). 3 files changed, +1058/-1. Parent issue: #233.

Checklist

  • All 9 endpoints implemented per acceptance criteria
  • Tenant scoping on all queries via _get_tenant() + DEFAULT_TENANT_SLUG (matches admin.py pattern)
  • require_admin dependency on every endpoint
  • Division filter on practices and events
  • event_type filter on events
  • is_active filter on practices
  • Program label mapping (boys->Kings, girls->Queens) via _DIVISION_LABELS
  • HTTP status codes correct: 201 create, 200 read/update, 204 delete
  • 404 on non-existent IDs (tenant-scoped lookups)
  • Pydantic validation for required fields
  • model_dump(exclude_unset=True) for partial updates -- correct pattern
  • Enum parsing helpers with 422 error messages
  • Router registered at /admin/schedule in main.py
  • Import added alphabetically in main.py
  • Follows jersey.py file structure pattern (inline schemas, APIRouter, dependency injection)
  • 25 endpoint tests + 14 existing model tests = 39 total
  • Tenant isolation tests (list exclusion, update 404, delete 404)
  • Unauthenticated access test
  • Auth override pattern matches test_coaches_api.py convention
  • 680/680 full suite passing, no regressions
  • ruff format + ruff check clean

Findings

No issues found. Clean implementation that follows established codebase conventions exactly.

VERDICT: APPROVED

## QA Review -- PR #236 ### Summary 9 admin CRUD endpoints for schedule management (practices + events). 3 files changed, +1058/-1. Parent issue: #233. ### Checklist - [x] All 9 endpoints implemented per acceptance criteria - [x] Tenant scoping on all queries via `_get_tenant()` + `DEFAULT_TENANT_SLUG` (matches admin.py pattern) - [x] `require_admin` dependency on every endpoint - [x] Division filter on practices and events - [x] `event_type` filter on events - [x] `is_active` filter on practices - [x] Program label mapping (boys->Kings, girls->Queens) via `_DIVISION_LABELS` - [x] HTTP status codes correct: 201 create, 200 read/update, 204 delete - [x] 404 on non-existent IDs (tenant-scoped lookups) - [x] Pydantic validation for required fields - [x] `model_dump(exclude_unset=True)` for partial updates -- correct pattern - [x] Enum parsing helpers with 422 error messages - [x] Router registered at `/admin/schedule` in main.py - [x] Import added alphabetically in main.py - [x] Follows `jersey.py` file structure pattern (inline schemas, APIRouter, dependency injection) - [x] 25 endpoint tests + 14 existing model tests = 39 total - [x] Tenant isolation tests (list exclusion, update 404, delete 404) - [x] Unauthenticated access test - [x] Auth override pattern matches `test_coaches_api.py` convention - [x] 680/680 full suite passing, no regressions - [x] ruff format + ruff check clean ### Findings No issues found. Clean implementation that follows established codebase conventions exactly. **VERDICT: APPROVED**
forgejo_admin deleted branch 233-schedule-api-endpoints 2026-03-28 23:18:40 +00:00
Sign in to join this conversation.
No description provided.