Madiwka преди 1 година
родител
ревизия
150031c9a8
променени са 2 файла, в които са добавени 16 реда и са изтрити 14 реда
  1. +12
    -12
      app/db/repository/vehicle.py
  2. +4
    -2
      app/schemas/vehicle.py

+ 12
- 12
app/db/repository/vehicle.py Целия файл

@@ -76,23 +76,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":
return "driverNotFound"
vehicle_object.Capacity = vehicle.Capacity
vehicle_object.Year = vehicle.Year
#res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
#if res == "nodriver":
# return "driverNotFound"
#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




+ 4
- 2
app/schemas/vehicle.py Целия файл

@@ -26,8 +26,10 @@ class OutputVehicle(BaseModel):
Status: str


class UpdateVehicle(OutputVehicle):
pass
class UpdateVehicle(BaseModel):
Mileage: int
Status: str


class VehicleLocation(BaseModel):


Зареждане…
Отказ
Запис