From 4ca0ea9c8b5d22fbba0d1fca7a27924f11e9dbfb Mon Sep 17 00:00:00 2001 From: shahzeydyfah Date: Sat, 23 Mar 2024 14:26:21 +0330 Subject: [PATCH] fix:design progress --- app/repositories/design_progress.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/repositories/design_progress.py b/app/repositories/design_progress.py index 2f5bc2c..3ea6747 100644 --- a/app/repositories/design_progress.py +++ b/app/repositories/design_progress.py @@ -66,7 +66,26 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]): return await self.get(get_record) async def check_complete(self,get_record:GetRecord): result = False - if get_record.type and get_record.type < 7: + if get_record.type : + if get_record.type < 7: + progress = await use_collection(COLLECTION).find( + {"project_id": get_record.project_id, "type": int(get_record.type)+1}).to_list(None) + if progress: + ids = [i["_id"] for i in progress] + records = await use_collection('design_progress_record').find_one( + {"design_progress_id": {"$in":ids}}) + if records: + raise HTTPException(status_code=200, detail='next record is exist') + if get_record.type > 1: + progress = await use_collection(COLLECTION).find_one( + {"project_id": get_record.project_id, "type": int(get_record.type) - 1, "completed_at":{"$exists":1}}) + if not progress: + raise HTTPException(status_code=200, detail='before type not complete') + return result + + async def check_create_complete(self,get_record:GetRecord): + result = False + if get_record.type and get_record.type >1: progress = await use_collection(COLLECTION).find( {"project_id": get_record.project_id, "type": int(get_record.type)+1}).to_list(None) if progress: