Files
personal-ai-assistant/backend/app/templates/pdf/seeds/basic_ru.html
dolgolyov.alexei bb53eeee8e 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>
2026-03-19 15:32:35 +03:00

71 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: 'Helvetica', 'Arial', sans-serif; font-size: 12pt; color: #333; margin: 40px; }
h1 { color: #1a7a8a; border-bottom: 2px solid #1a7a8a; padding-bottom: 8px; }
h2 { color: #2a5a6a; margin-top: 24px; }
.header { margin-bottom: 24px; }
.header p { margin: 2px 0; color: #666; }
.section { margin-bottom: 20px; }
.entry { background: #f5f9fa; padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; }
.entry .cat { font-size: 10pt; color: #888; text-transform: uppercase; }
.entry .title { font-weight: bold; }
.entry .badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 9pt; }
.badge-critical { background: #fee; color: #c33; }
.badge-high { background: #fff3e0; color: #e65100; }
.badge-medium { background: #e3f2fd; color: #1565c0; }
.badge-low { background: #f5f5f5; color: #666; }
.doc { border: 1px solid #ddd; padding: 12px; border-radius: 6px; margin-bottom: 10px; }
.doc .fname { font-weight: bold; color: #1a7a8a; }
.doc .excerpt { font-size: 10pt; color: #555; white-space: pre-wrap; max-height: 200px; overflow: hidden; }
.footer { margin-top: 40px; padding-top: 12px; border-top: 1px solid #ddd; font-size: 9pt; color: #999; }
</style>
</head>
<body>
<div class="header">
<h1>{{ title }}</h1>
<p>Подготовлено для: {{ user_name }}</p>
<p>Дата: {{ generated_at }}</p>
</div>
{% if memories %}
<div class="section">
<h2>Ключевая информация</h2>
{% for m in memories %}
<div class="entry">
<span class="cat">{{ m.category }}</span>
<span class="badge badge-{{ m.importance }}">{{ m.importance }}</span>
<div class="title">{{ m.title }}</div>
<div>{{ m.content }}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if documents %}
<div class="section">
<h2>Сводка по документам</h2>
{% for d in documents %}
<div class="doc">
<div class="fname">{{ d.original_filename }} ({{ d.doc_type }})</div>
<div class="excerpt">{{ d.excerpt }}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if ai_summary %}
<div class="section">
<h2>Резюме ИИ</h2>
<p>{{ ai_summary }}</p>
</div>
{% endif %}
<div class="footer">
Сгенерировано ИИ-ассистентом
</div>
</body>
</html>