fix: resolve audit report gaps across bulk imports, auth, scoping, and exports
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
from fastapi import APIRouter, Body, Depends, HTTPException, Query, status
|
||||
from fastapi import APIRouter, Body, Depends, File, HTTPException, Query, UploadFile, status
|
||||
from fastapi.responses import StreamingResponse
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
@@ -26,7 +26,7 @@ from ..schemas.calibration import (
|
||||
CalibrationStatusFilter,
|
||||
)
|
||||
from ..services.audit import log_audit
|
||||
from ..services.bulk_templates import build_calibration_template_xlsx
|
||||
from ..services.bulk_templates import build_calibration_template_xlsx, process_calibration_import
|
||||
from ..services.calculations import compute_schedule_status
|
||||
from ..services.permissions import Role
|
||||
from ..services.settings_service import get_setting_value
|
||||
@@ -211,6 +211,27 @@ def download_calibration_import_template(
|
||||
)
|
||||
|
||||
|
||||
@router.post("/bulk-import")
|
||||
def bulk_import_calibration(
|
||||
file: UploadFile = File(...),
|
||||
dry_run: bool = Query(False),
|
||||
skip_invalid: bool = Query(False),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(
|
||||
require_roles(Role.system_admin, Role.biomedical, Role.coordinator, Role.management)
|
||||
),
|
||||
):
|
||||
content = file.file.read()
|
||||
return process_calibration_import(
|
||||
db=db,
|
||||
filename=file.filename or "calibration.xlsx",
|
||||
content=content,
|
||||
user_id=current_user.id,
|
||||
dry_run=dry_run,
|
||||
skip_invalid=skip_invalid,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/plans", response_model=CalibrationPlanListOut)
|
||||
def list_calibration_plans(
|
||||
q: str = "",
|
||||
|
||||
Reference in New Issue
Block a user