From f582405340b4e12d1bf304d068f49d59b7011330 Mon Sep 17 00:00:00 2001 From: Madiwka3 Date: Tue, 28 Nov 2023 07:04:40 +0600 Subject: [PATCH] creator --- app/db/repository/fuelingtask.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/db/repository/fuelingtask.py b/app/db/repository/fuelingtask.py index e37b255..d0fa309 100644 --- a/app/db/repository/fuelingtask.py +++ b/app/db/repository/fuelingtask.py @@ -43,6 +43,7 @@ def create_fueling_task( driverobj["AssignedVehicle"] = driver.vehicle.__dict__ resobj = fueling_task_object.__dict__ resobj["Driver"] = driverobj + resobj["Creator"] = current_user ia = fueling_task_object.ImageAfter ib = fueling_task_object.ImageBefore if ia is not None: @@ -103,15 +104,18 @@ def get_all_fueling_tasks(db: Session): x = {"FuelingTasks": result} return x + def get_fuel_tasks_by_creator(creator_id: int, db: Session): print(f"Retrieving all fueling tasks created by user ID: {creator_id}") - fueling_tasks = db.query(FuelingTask).filter(FuelingTask.CreatedById == creator_id).all() + fueling_tasks = ( + db.query(FuelingTask).filter(FuelingTask.CreatedById == creator_id).all() + ) result = [] for task in fueling_tasks: res = task.__dict__ - res["ImageBefore"] = None - res["ImageAfter"] = None + res["ImageBefore"] = None + res["ImageAfter"] = None res["Creator"] = task.CreatedById driver = get_user_by_id(task.DriverId, role="Driver", db=db) driver_obj = driver.__dict__