From 6dd12c94b6e11787b144d9e2dc01c81777e613e6 Mon Sep 17 00:00:00 2001 From: Madiwka3 Date: Thu, 23 Nov 2023 21:51:54 +0600 Subject: [PATCH] minimality --- app/apis/v1/route_maintenancejob.py | 18 ++++++++++-------- app/schemas/maintenancejob.py | 12 +++++++++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/apis/v1/route_maintenancejob.py b/app/apis/v1/route_maintenancejob.py index ed64d30..f3e10f1 100644 --- a/app/apis/v1/route_maintenancejob.py +++ b/app/apis/v1/route_maintenancejob.py @@ -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), diff --git a/app/schemas/maintenancejob.py b/app/schemas/maintenancejob.py index de117f0..79bd198 100644 --- a/app/schemas/maintenancejob.py +++ b/app/schemas/maintenancejob.py @@ -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