Phase 5 Batch 5 Task 5.18: Report Generator PDF-Support & Druck-Funktionen
- Installed WeasyPrint 69.0 for PDF generation - Created 5 Jinja2 HTML templates: contact_list, calendar_week, calendar_month, company_list, audit_log - All templates: A4 landscape, print-optimized CSS (@media print, page margins) - Extended output_format in schemas.py: added pdf and print - Created pdf_generator.py: Jinja2 + WeasyPrint pipeline with preset support - Modified routes.py: PDF/print generation, preset endpoints (/presets, /presets/generate) - Added RBAC (require_permission) to all report endpoints - Generate endpoints return StreamingResponse (file download) directly - 7 backend tests: presets listing, PDF/CSV generation, template CRUD, RBAC
This commit is contained in:
@@ -12,7 +12,7 @@ class TemplateCreate(BaseModel):
|
||||
description: str = Field("", max_length=2000)
|
||||
template_type: str = Field("jinja2", pattern="^(jinja2|sql)$")
|
||||
content: str = Field(..., min_length=1)
|
||||
output_format: str = Field("csv", pattern="^(csv|excel|json)$")
|
||||
output_format: str = Field("csv", pattern="^(csv|excel|json|pdf|print)$")
|
||||
|
||||
|
||||
class TemplateUpdate(BaseModel):
|
||||
@@ -20,7 +20,7 @@ class TemplateUpdate(BaseModel):
|
||||
description: str | None = Field(None, max_length=2000)
|
||||
template_type: str | None = Field(None, pattern="^(jinja2|sql)$")
|
||||
content: str | None = None
|
||||
output_format: str | None = Field(None, pattern="^(csv|excel|json)$")
|
||||
output_format: str | None = Field(None, pattern="^(csv|excel|json|pdf|print)$")
|
||||
|
||||
|
||||
class TemplateResponse(BaseModel):
|
||||
@@ -39,6 +39,28 @@ class TemplateResponse(BaseModel):
|
||||
class ReportGenerateRequest(BaseModel):
|
||||
template_id: str = Field(..., min_length=1)
|
||||
data: dict = Field(default_factory=dict)
|
||||
output_format: str | None = Field(None, pattern="^(csv|excel|json|pdf|print)$")
|
||||
|
||||
|
||||
class PresetReportRequest(BaseModel):
|
||||
"""Request to generate a preset report by name."""
|
||||
|
||||
preset: str = Field(
|
||||
...,
|
||||
pattern="^(contact_list|calendar_week|calendar_month|company_list|audit_log)$",
|
||||
)
|
||||
output_format: str = Field("pdf", pattern="^(csv|excel|json|pdf|print)$")
|
||||
parameters: dict = Field(default_factory=dict)
|
||||
|
||||
|
||||
class PresetReportInfo(BaseModel):
|
||||
"""Metadata for a preset report template."""
|
||||
|
||||
key: str
|
||||
name: str
|
||||
description: str
|
||||
icon: str
|
||||
output_formats: list[str]
|
||||
|
||||
|
||||
class ReportResponse(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user