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:
@@ -99,6 +99,7 @@ AI_TOOLS = [
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"title": {"type": "string", "description": "Title for the PDF report"},
|
||||
"template_id": {"type": "string", "description": "Optional UUID of a specific PDF template to use"},
|
||||
},
|
||||
"required": ["title"],
|
||||
},
|
||||
@@ -174,7 +175,8 @@ async def _execute_tool(
|
||||
|
||||
elif tool_name == "generate_pdf":
|
||||
from app.services.pdf_service import generate_pdf_report
|
||||
pdf = await generate_pdf_report(db, user_id, title=tool_input["title"])
|
||||
tmpl_id = uuid.UUID(tool_input["template_id"]) if tool_input.get("template_id") else None
|
||||
pdf = await generate_pdf_report(db, user_id, title=tool_input["title"], template_id=tmpl_id)
|
||||
await db.commit()
|
||||
return json.dumps({
|
||||
"status": "generated",
|
||||
|
||||
Reference in New Issue
Block a user