|
|
@@ -6,6 +6,7 @@ from db.repository.fuelingtask import ( |
|
|
|
delete_fueling_task, |
|
|
|
get_fueling_task_by_id, |
|
|
|
get_all_fueling_tasks, |
|
|
|
get_fuel_tasks_by_creator, |
|
|
|
) |
|
|
|
from schemas.fuelingtask import ( |
|
|
|
CreateFuelingTask, |
|
|
@@ -87,3 +88,17 @@ def get_all( |
|
|
|
) |
|
|
|
tasks = get_all_fueling_tasks(db) |
|
|
|
return tasks |
|
|
|
|
|
|
|
@router.get("/creator/{creator_id}", response_model=OutputFuelingTaskList, status_code=status.HTTP_200_OK) |
|
|
|
def get_fuel_tasks_by_creator_id( |
|
|
|
creator_id: int, |
|
|
|
db: Session = Depends(get_db), |
|
|
|
current_user: User = Depends(get_current_user), |
|
|
|
): |
|
|
|
if current_user.Role != "Admin" and current_user.Role != "Fueling": |
|
|
|
raise HTTPException( |
|
|
|
status_code=403, detail="You are not authorized to perform this action" |
|
|
|
) |
|
|
|
|
|
|
|
tasks = get_fuel_tasks_by_creator(creator_id, db) |
|
|
|
return tasks |