Browse Source

minimality

main
Madiwka3 1 year ago
parent
commit
6dd12c94b6
2 changed files with 21 additions and 9 deletions
  1. +10
    -8
      app/apis/v1/route_maintenancejob.py
  2. +11
    -1
      app/schemas/maintenancejob.py

+ 10
- 8
app/apis/v1/route_maintenancejob.py View File

@@ -9,7 +9,11 @@ from db.repository.maintenancejob import (
change_maintenance_status, change_maintenance_status,
) )
from typing import List from typing import List
from schemas.maintenancejob import CreateMaintenanceJob, OutputMaintenanceJob
from schemas.maintenancejob import (
CreateMaintenanceJob,
OutputMaintenanceJob,
OutputMinimalMaintenanceJob,
)
from schemas.carpart import CreateCarPart, ShowCarPart from schemas.carpart import CreateCarPart, ShowCarPart
from db.models.user import User from db.models.user import User
from apis.v1.route_auth import get_current_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" 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": 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 return maintenancejob_res




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




@router.get( @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( def get_all_maintenancejobs(
db: Session = Depends(get_db), db: Session = Depends(get_db),


+ 11
- 1
app/schemas/maintenancejob.py View File

@@ -20,4 +20,14 @@ class OutputMaintenanceJob(BaseModel):
TotalCost: float TotalCost: float
Vehicle: OutputVehicle Vehicle: OutputVehicle
FinishedBy: Optional[ShowUser] 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

Loading…
Cancel
Save