Browse Source

vehicle init

main
Madiwka3 1 year ago
parent
commit
cffec0a612
2 changed files with 6 additions and 3 deletions
  1. +2
    -2
      app/apis/v1/route_fuelingtask.py
  2. +4
    -1
      app/db/repository/vehicle.py

+ 2
- 2
app/apis/v1/route_fuelingtask.py View File

@@ -25,7 +25,7 @@ def create_fuelingtask(
db: Session = Depends(get_db), db: Session = Depends(get_db),
current_user: User = Depends(get_current_user), current_user: User = Depends(get_current_user),
): ):
if current_user.Role != "FuelingPerson" and current_user.Role != "Admin":
if current_user.Role != "Fueling" and current_user.Role != "Admin":
raise HTTPException( raise HTTPException(
status_code=403, detail="You are not authorized to perform this action" status_code=403, detail="You are not authorized to perform this action"
) )
@@ -51,7 +51,7 @@ def get_fuelingtask(
db: Session = Depends(get_db), db: Session = Depends(get_db),
current_user: User = Depends(get_current_user), current_user: User = Depends(get_current_user),
): ):
if current_user.Role != "FuelingPerson" and current_user.Role != "Admin":
if current_user.Role != "Fueling" and current_user.Role != "Admin":
raise HTTPException( raise HTTPException(
status_code=403, detail="You are not authorized to perform this action" status_code=403, detail="You are not authorized to perform this action"
) )


+ 4
- 1
app/db/repository/vehicle.py View File

@@ -8,7 +8,10 @@ from db.repository.user import get_car_driver
def create_new_vehicle(vehicle: CreateVehicle, db: Session): def create_new_vehicle(vehicle: CreateVehicle, db: Session):
print("Creating new vehicle" + str(vehicle)) print("Creating new vehicle" + str(vehicle))
vehicle_object = Vehicle( vehicle_object = Vehicle(
**vehicle.model_dump(), Fuel=0, Status="Inactive", CurrentLocation=[]
**vehicle.model_dump(),
Fuel=0,
Status="Inactive",
CurrentLocation=["0.000", "0.000"]
) )
db.add(vehicle_object) db.add(vehicle_object)
db.commit() db.commit()


Loading…
Cancel
Save