Nuevos cambios en el backend
This commit is contained in:
@@ -4,7 +4,9 @@ from typing import Annotated
|
||||
from fastapi import APIRouter, Depends, Response
|
||||
|
||||
from app.api.dependencies import get_exam_service
|
||||
from app.core.auth import get_current_user
|
||||
from app.models.exam import ExportFormat
|
||||
from app.models.user import User
|
||||
from app.services.exam_service import ExamService
|
||||
|
||||
router = APIRouter(prefix="/export", tags=["exports"])
|
||||
@@ -13,25 +15,28 @@ router = APIRouter(prefix="/export", tags=["exports"])
|
||||
@router.get("/xml/{template_id}")
|
||||
def export_xml(
|
||||
template_id: uuid.UUID,
|
||||
current_user: Annotated[User, Depends(get_current_user)],
|
||||
service: Annotated[ExamService, Depends(get_exam_service)],
|
||||
) -> Response:
|
||||
export = service.export(template_id, ExportFormat.XML)
|
||||
export = service.export(current_user.id, template_id, ExportFormat.XML)
|
||||
return Response(content=export.content, media_type="application/xml")
|
||||
|
||||
|
||||
@router.get("/txt/{template_id}")
|
||||
def export_txt(
|
||||
template_id: uuid.UUID,
|
||||
current_user: Annotated[User, Depends(get_current_user)],
|
||||
service: Annotated[ExamService, Depends(get_exam_service)],
|
||||
) -> Response:
|
||||
export = service.export(template_id, ExportFormat.TXT)
|
||||
export = service.export(current_user.id, template_id, ExportFormat.TXT)
|
||||
return Response(content=export.content, media_type="text/plain; charset=utf-8")
|
||||
|
||||
|
||||
@router.get("/json/{template_id}")
|
||||
def export_json(
|
||||
template_id: uuid.UUID,
|
||||
current_user: Annotated[User, Depends(get_current_user)],
|
||||
service: Annotated[ExamService, Depends(get_exam_service)],
|
||||
) -> Response:
|
||||
export = service.export(template_id, ExportFormat.JSON)
|
||||
export = service.export(current_user.id, template_id, ExportFormat.JSON)
|
||||
return Response(content=export.content, media_type="application/json")
|
||||
|
||||
Reference in New Issue
Block a user