diff --git a/app/repositories/design_progress.py b/app/repositories/design_progress.py index 3ea6747..d8a2b2c 100644 --- a/app/repositories/design_progress.py +++ b/app/repositories/design_progress.py @@ -67,6 +67,12 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]): async def check_complete(self,get_record:GetRecord): result = False if get_record.type : + 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') 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) @@ -76,11 +82,7 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]): {"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):