Phase 8: Customizable PDF Templates — locale support, admin editor, seed templates

Backend:
- PdfTemplate model with locale field + UNIQUE(name, locale) constraint
- Migration 007: pdf_templates table + template_id FK on generated_pdfs
- Template service: CRUD, Jinja2 validation, render preview with sample data
- Admin endpoints: CRUD /admin/pdf-templates + POST preview
- User endpoint: GET /pdf/templates (active templates list)
- pdf_service: resolves template from DB by ID or falls back to default
  for the appropriate locale
- AI generate_pdf tool accepts optional template_id
- Seed script + 4 HTML template files:
  - Basic Report (en/ru) — general-purpose report
  - Medical Report (en/ru) — health-focused with disclaimers

Frontend:
- Admin PDF templates page with editor, locale selector, live preview (iframe),
  template variables reference panel
- PDF page: template selector dropdown in generation form
- API clients for admin CRUD + user template listing
- Sidebar: admin templates link
- English + Russian translations

Also added Phase 9 (OAuth) and Phase 10 (Rate Limits) placeholders to GeneralPlan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 15:32:35 +03:00
parent b0790d719c
commit bb53eeee8e
26 changed files with 1077 additions and 16 deletions

View File

@@ -245,6 +245,24 @@ Daily scheduled job (APScheduler, 8 AM) reviews each user's memory + recent docs
- [x] Phase completed
- Summary: Security audit, file upload validation, performance tuning, structured logging, production Docker images, health checks, backup strategy, documentation
### Phase 8: Customizable PDF Templates
- **Status**: COMPLETED
- [x] Subplan created (`plans/phase-8-pdf-templates.md`)
- [x] Phase completed
- Summary: Admin-managed Jinja2 PDF templates in DB with locale support (en/ru), template selector for users/AI, live preview editor, basic + medical seed templates
### Phase 9: OAuth & Account Switching
- **Status**: NOT STARTED
- [ ] Subplan created (`plans/phase-9-oauth.md`)
- [ ] Phase completed
- Summary: OAuth (Google, GitHub), account switching UI, multiple stored sessions
### Phase 10: Per-User Rate Limits
- **Status**: NOT STARTED
- [ ] Subplan created (`plans/phase-10-rate-limits.md`)
- [ ] Phase completed
- Summary: Per-user AI message rate limits, admin-configurable limits, usage tracking
---
## Key Design Decisions