Spaces:
Sleeping
Sleeping
Update src/services/cv_router.py
Browse files
src/services/cv_router.py
CHANGED
|
@@ -30,8 +30,6 @@ class CVResponse(BaseModel):
|
|
| 30 |
async def create_cv(cv: CVCreate, db: AsyncIOMotorDatabase = Depends(lambda: mongo_db)):
|
| 31 |
cv_entry = cv.model_dump(by_alias=True, exclude_unset=True)
|
| 32 |
cv_id = await CVModel.create(db, CVModel.collection_name, cv_entry)
|
| 33 |
-
|
| 34 |
-
# MODIFICATION : Retourne directement l'objet Pydantic pour sérialisation
|
| 35 |
cv_entry['id'] = cv_id
|
| 36 |
return CVResponse(**cv_entry)
|
| 37 |
|
|
@@ -43,7 +41,5 @@ async def get_cv_by_id(cv_id: str, db: AsyncIOMotorDatabase = Depends(lambda: mo
|
|
| 43 |
cv = await CVModel.get(db, CVModel.collection_name, {"_id": ObjectId(cv_id)})
|
| 44 |
if cv is None:
|
| 45 |
raise HTTPException(status_code=404, detail="CV not found")
|
| 46 |
-
|
| 47 |
-
# MODIFICATION : Convertit explicitement l'ObjectId en str avant de retourner l'objet
|
| 48 |
-
cv['id'] = str(cv['_id'])
|
| 49 |
return CVResponse(**cv)
|
|
|
|
| 30 |
async def create_cv(cv: CVCreate, db: AsyncIOMotorDatabase = Depends(lambda: mongo_db)):
|
| 31 |
cv_entry = cv.model_dump(by_alias=True, exclude_unset=True)
|
| 32 |
cv_id = await CVModel.create(db, CVModel.collection_name, cv_entry)
|
|
|
|
|
|
|
| 33 |
cv_entry['id'] = cv_id
|
| 34 |
return CVResponse(**cv_entry)
|
| 35 |
|
|
|
|
| 41 |
cv = await CVModel.get(db, CVModel.collection_name, {"_id": ObjectId(cv_id)})
|
| 42 |
if cv is None:
|
| 43 |
raise HTTPException(status_code=404, detail="CV not found")
|
| 44 |
+
cv['id'] = str(cv.pop('_id'))
|
|
|
|
|
|
|
| 45 |
return CVResponse(**cv)
|