Bläddra i källkod

minimality

main
Madiwka3 1 år sedan
förälder
incheckning
6dd12c94b6
2 ändrade filer med 21 tillägg och 9 borttagningar
  1. +10
    -8
      app/apis/v1/route_maintenancejob.py
  2. +11
    -1
      app/schemas/maintenancejob.py

+ 10
- 8
app/apis/v1/route_maintenancejob.py Visa fil

@@ -9,7 +9,11 @@ from db.repository.maintenancejob import (
change_maintenance_status,
)
from typing import List
from schemas.maintenancejob import CreateMaintenanceJob, OutputMaintenanceJob
from schemas.maintenancejob import (
CreateMaintenanceJob,
OutputMaintenanceJob,
OutputMinimalMaintenanceJob,
)
from schemas.carpart import CreateCarPart, ShowCarPart
from db.models.user import User
from apis.v1.route_auth import get_current_user
@@ -28,13 +32,9 @@ def create_maintenancejob(
status_code=403, detail="You are not authorized to perform this action"
)

maintenancejob_res = create_new_maintenancejob(
maintenancejob=maintenancejob, db=db
)
maintenancejob_res = create_new_maintenancejob(maintenancejob=maintenancejob, db=db)
if maintenancejob_res == "nodriver":
raise HTTPException(
status_code=404, detail="This car has no driver"
)
raise HTTPException(status_code=404, detail="This car has no driver")
return maintenancejob_res


@@ -57,7 +57,9 @@ def create_carpart(


@router.get(
"/", response_model=List[OutputMaintenanceJob], status_code=status.HTTP_200_OK
"/",
response_model=List[OutputMinimalMaintenanceJob],
status_code=status.HTTP_200_OK,
)
def get_all_maintenancejobs(
db: Session = Depends(get_db),


+ 11
- 1
app/schemas/maintenancejob.py Visa fil

@@ -20,4 +20,14 @@ class OutputMaintenanceJob(BaseModel):
TotalCost: float
Vehicle: OutputVehicle
FinishedBy: Optional[ShowUser]
Status: str
Status: str


class OutputMinimalMaintenanceJob(BaseModel):
Id: int
Description: str
Date: datetime
TotalCost: float
Vehicle: OutputVehicle
FinishedBy: Optional[ShowUser]
Status: str

Laddar…
Avbryt
Spara