Browse Source

Vehicle update updated

main
Madiwka3 1 year ago
parent
commit
9370ae4103
2 changed files with 19 additions and 14 deletions
  1. +11
    -11
      app/db/repository/vehicle.py
  2. +8
    -3
      app/schemas/vehicle.py

+ 11
- 11
app/db/repository/vehicle.py View File

@@ -87,23 +87,23 @@ def replace_vehicle_data(id: int, vehicle: UpdateVehicle, db: Session):
vehicle_object = vehicle_db.first() vehicle_object = vehicle_db.first()
if not vehicle_object: if not vehicle_object:
return "vehiclenotfound" return "vehiclenotfound"
#vehicle_object.CurrentLocation = vehicle.CurrentLocation
#vehicle_object.Fuel = vehicle.Fuel
#vehicle_object.LicensePlate = vehicle.LicensePlate
#vehicle_object.DriverHistory = vehicle.DriverHistory
#vehicle_object.Type = vehicle.Type
# vehicle_object.CurrentLocation = vehicle.CurrentLocation
vehicle_object.Fuel = vehicle.Fuel
vehicle_object.LicensePlate = vehicle.LicensePlate
# vehicle_object.DriverHistory = vehicle.DriverHistory
vehicle_object.Type = vehicle.Type
vehicle_object.Mileage = vehicle.Mileage vehicle_object.Mileage = vehicle.Mileage
#vehicle_object.Model = vehicle.Model
vehicle_object.Model = vehicle.Model
vehicle_object.Status = vehicle.Status vehicle_object.Status = vehicle.Status
#res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
#if res == "nodriver":
# res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
# if res == "nodriver":
# return "driverNotFound" # return "driverNotFound"
#vehicle_object.Capacity = vehicle.Capacity
#vehicle_object.Year = vehicle.Year
vehicle_object.Capacity = vehicle.Capacity
vehicle_object.Year = vehicle.Year
print(vehicle_object) print(vehicle_object)
db.add(vehicle_object) db.add(vehicle_object)
db.commit() db.commit()
#vehicle_object.AssignedDriver = vehicle.AssignedDriver
# vehicle_object.AssignedDriver = vehicle.AssignedDriver
return vehicle_object return vehicle_object






+ 8
- 3
app/schemas/vehicle.py View File

@@ -28,9 +28,14 @@ class OutputVehicle(BaseModel):




class UpdateVehicle(BaseModel): class UpdateVehicle(BaseModel):
Mileage: int
Status: str
Mileage: Optional[int]
Status: Optional[str]
Capacity: Optional[int]
Model: Optional[str]
Year: Optional[int]
LicensePlate: Optional[str]
Fuel: Optional[int] = 0
Type: Optional[str]




class VehicleLocation(BaseModel): class VehicleLocation(BaseModel):


Loading…
Cancel
Save