from fastapi import Depends, APIRouter, HTTPException, status from requests import Session from apis.v1.route_auth import get_current_user from db.models.user import User from db.repository.report import get_repot_jobsdone_by_driver from db.session import get_db router = APIRouter() @router.get("/jobsdone/{driver_id}", status_code=status.HTTP_200_OK) def get_report_jobsdone(driver_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)): if current_user.Role != "Admin": raise HTTPException( status_code=403, detail="You are not authorized to perform this action" ) report = get_repot_jobsdone_by_driver(driver_id, db) if report == "notdriver": raise HTTPException( status_code=404, detail=f"Driver with id {driver_id} not found" ) return report