浏览代码

creator

main
Madiwka3 11 个月前
父节点
当前提交
f582405340
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. +7
    -3
      app/db/repository/fuelingtask.py

+ 7
- 3
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__


正在加载...
取消
保存