diff --git a/forms-flow-api/src/formsflow_api/models/draft.py b/forms-flow-api/src/formsflow_api/models/draft.py index 85cca8d995..63171a532e 100644 --- a/forms-flow-api/src/formsflow_api/models/draft.py +++ b/forms-flow-api/src/formsflow_api/models/draft.py @@ -54,6 +54,14 @@ def update(self, draft_info: dict): ) self.save_and_flush() + def update_draft_data_and_commit(self, draft_info: dict): + """Update & commit draft data.""" + self.update_from_dict( + ["data"], + draft_info, + ) + self.commit() + @classmethod def get_by_id(cls, draft_id: str, user_id: str) -> Draft: """Retrieves the draft entry by id.""" diff --git a/forms-flow-api/src/formsflow_api/services/draft.py b/forms-flow-api/src/formsflow_api/services/draft.py index 629bbd852e..b12dff5388 100644 --- a/forms-flow-api/src/formsflow_api/services/draft.py +++ b/forms-flow-api/src/formsflow_api/services/draft.py @@ -83,7 +83,7 @@ def update_draft(draft_id: int, data, **kwargs): user_id: str = user.user_name or ANONYMOUS_USER draft = Draft.get_by_id(draft_id, user_id) if draft: - draft.update(data) + draft.update_draft_data_and_commit(data) else: raise BusinessException(BusinessErrorCode.DRAFT_APPLICATION_NOT_FOUND)