24 lines
761 B
Python
24 lines
761 B
Python
from fastapi import APIRouter, Depends, Response
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
from app.models.user import User
|
|
from app.services import report_service
|
|
from app.api.deps import get_current_user
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/projects/{project_id}/download")
|
|
def download_report(
|
|
project_id: int,
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
content = report_service.generate_classification_report(db, project_id)
|
|
return Response(
|
|
content=content,
|
|
media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
headers={"Content-Disposition": f"attachment; filename=report_project_{project_id}.docx"},
|
|
)
|