feat: implement location events & error handling (Step 10.2)

- Add LocationService with create/rename/archive methods
- Add LocationProjection for event handling
- Add admin-only location management routes at /locations
- Add error response helpers (error_response, error_toast, success_toast)
- Add toast handler JS to base template for HX-Trigger notifications
- Update seeds.py to emit LocationCreated events per spec §23
- Archived locations block animal moves with 422 error

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 17:48:16 +00:00
parent 5ba068b36a
commit 229842fb45
14 changed files with 1896 additions and 28 deletions

14
PLAN.md
View File

@@ -379,19 +379,19 @@ Check off items as completed. Each phase builds on the previous.
- [x] E2E test #6: Deletes: recorder vs admin cascade (test_e2e_deletion.py)
- [x] E2E test #7: Harvest with yields (test_e2e_harvest.py)
- [x] E2E test #8: Optimistic lock with confirm (test_e2e_optimistic_lock.py)
- [ ] **Commit checkpoint**
- [x] **Commit checkpoint** (5ba068b)
NOTE: Tests #1-5 in test_e2e_stats_progression.py have documented discrepancies with
spec values due to integer truncation of bird-days and timeline differences. The
tests verify implementation consistency, not exact spec values.
### Step 10.2: Location Events & Error Handling
- [ ] Implement LocationCreated (idempotent for seeding)
- [ ] Implement LocationRenamed
- [ ] Implement LocationArchived
- [ ] Standardize error responses (422, 409, 401/403)
- [ ] Toast via HX-Trigger
- [ ] Write tests for location events and error rendering
- [x] Implement LocationCreated (idempotent for seeding)
- [x] Implement LocationRenamed
- [x] Implement LocationArchived
- [x] Standardize error responses (422, 409, 401/403)
- [x] Toast via HX-Trigger
- [x] Write tests for location events and error rendering
- [ ] **Commit checkpoint**
### Step 10.3: CLI, Docker & Deployment