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

@@ -38,7 +38,8 @@
"context": "Context",
"skills": "Skills",
"personal_context": "My Context",
"pdf": "PDF Reports"
"pdf": "PDF Reports",
"pdf_templates": "Templates"
},
"dashboard": {
"welcome": "Welcome, {{name}}",
@@ -157,7 +158,29 @@
"title": "PDF Reports",
"generate": "Generate PDF",
"title_placeholder": "Report title...",
"no_pdfs": "No PDF reports generated yet."
"no_pdfs": "No PDF reports generated yet.",
"template": "Template",
"default_template": "Default template"
},
"pdf_templates": {
"title": "PDF Templates",
"create": "Create Template",
"edit": "Edit Template",
"no_templates": "No templates yet.",
"default": "Default",
"inactive": "Inactive",
"name": "Name",
"locale": "Language",
"description": "Description",
"html_content": "HTML Template",
"preview": "Preview",
"variables_ref": "Template Variables Reference",
"var_title": "Report title",
"var_user_name": "User's full name",
"var_generated_at": "Generation timestamp",
"var_memories": "List of memory entries (category, title, content, importance)",
"var_documents": "List of documents (original_filename, doc_type, excerpt)",
"var_ai_summary": "AI-generated summary (optional)"
},
"admin_users": {
"title": "User Management",

View File

@@ -38,7 +38,8 @@
"context": "Контекст",
"skills": "Навыки",
"personal_context": "Мой контекст",
"pdf": "PDF отчёты"
"pdf": "PDF отчёты",
"pdf_templates": "Шаблоны"
},
"dashboard": {
"welcome": "Добро пожаловать, {{name}}",
@@ -157,7 +158,29 @@
"title": "PDF отчёты",
"generate": "Сгенерировать PDF",
"title_placeholder": "Название отчёта...",
"no_pdfs": "PDF отчёты ещё не создавались."
"no_pdfs": "PDF отчёты ещё не создавались.",
"template": "Шаблон",
"default_template": "Шаблон по умолчанию"
},
"pdf_templates": {
"title": "Шаблоны PDF",
"create": "Создать шаблон",
"edit": "Редактировать шаблон",
"no_templates": "Шаблонов пока нет.",
"default": "По умолчанию",
"inactive": "Неактивен",
"name": "Название",
"locale": "Язык",
"description": "Описание",
"html_content": "HTML шаблон",
"preview": "Предпросмотр",
"variables_ref": "Справка по переменным шаблона",
"var_title": "Заголовок отчёта",
"var_user_name": "Полное имя пользователя",
"var_generated_at": "Дата и время генерации",
"var_memories": "Список записей памяти (category, title, content, importance)",
"var_documents": "Список документов (original_filename, doc_type, excerpt)",
"var_ai_summary": "Резюме от ИИ (необязательно)"
},
"admin_users": {
"title": "Управление пользователями",