Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix draft data not saved while update #1999

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions forms-flow-api/src/formsflow_api/models/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-api/src/formsflow_api/services/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading