Some checks failed
Build & Push Docker / build (push) Has been cancelled
- Remove all Excel code (import, export, template, pandas, openpyxl) - New canvas-based schedule editor with drag & drop (interact.js) - Modern 3-panel UI: sidebar, canvas, documentation tab - New data model: Block with id/date/start/end, ProgramType with id/name/color - Clean API: GET /api/health, POST /api/validate, GET /api/sample, POST /api/generate-pdf - Rewritten PDF generator using ScenarioDocument directly (no DataFrame) - Professional PDF output: dark header, colored blocks, merged cells, legend, footer - Sample JSON: "Zimní výjezd oddílu" with 11 blocks, 3 program types - 30 tests passing (API, core models, PDF generation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
783 B
Python
28 lines
783 B
Python
"""PDF generation API endpoint."""
|
|
|
|
from io import BytesIO
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
from fastapi.responses import StreamingResponse
|
|
|
|
from app.models.event import ScenarioDocument
|
|
from app.core.validator import ScenarsError
|
|
from app.core.pdf_generator import generate_pdf
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post("/generate-pdf")
|
|
async def generate_pdf_endpoint(doc: ScenarioDocument):
|
|
"""Generate PDF timetable from ScenarioDocument."""
|
|
try:
|
|
pdf_bytes = generate_pdf(doc)
|
|
except ScenarsError as e:
|
|
raise HTTPException(status_code=422, detail=str(e))
|
|
|
|
return StreamingResponse(
|
|
BytesIO(pdf_bytes),
|
|
media_type="application/pdf",
|
|
headers={"Content-Disposition": "attachment; filename=scenar_timetable.pdf"}
|
|
)
|