Przeglądaj źródła

Vehicle update updated

main
Madiwka3 1 rok temu
rodzic
commit
9370ae4103
2 zmienionych plików z 19 dodań i 14 usunięć
  1. +11
    -11
      app/db/repository/vehicle.py
  2. +8
    -3
      app/schemas/vehicle.py

+ 11
- 11
app/db/repository/vehicle.py Wyświetl plik

@@ -87,23 +87,23 @@ def replace_vehicle_data(id: int, vehicle: UpdateVehicle, db: Session):
vehicle_object = vehicle_db.first()
if not vehicle_object:
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.Model = vehicle.Model
vehicle_object.Model = vehicle.Model
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"
#vehicle_object.Capacity = vehicle.Capacity
#vehicle_object.Year = vehicle.Year
vehicle_object.Capacity = vehicle.Capacity
vehicle_object.Year = vehicle.Year
print(vehicle_object)
db.add(vehicle_object)
db.commit()
#vehicle_object.AssignedDriver = vehicle.AssignedDriver
# vehicle_object.AssignedDriver = vehicle.AssignedDriver
return vehicle_object




+ 8
- 3
app/schemas/vehicle.py Wyświetl plik

@@ -28,9 +28,14 @@ class OutputVehicle(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):


Ładowanie…
Anuluj
Zapisz