Skip to content

Commit 4844022

Browse files
committed
Fix tests by handling new submission draft
1 parent a37d931 commit 4844022

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

hypha/apply/funds/models/submissions.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,10 @@ def from_draft(self) -> Self:
662662
Returns:
663663
Self with the `form_data` attribute updated.
664664
"""
665-
self.form_data = self.deserialised_data(
666-
self, self.draft_revision.form_data, self.form_fields
667-
)
665+
if self.draft_revision:
666+
self.form_data = self.deserialised_data(
667+
self, self.draft_revision.form_data, self.form_fields
668+
)
668669

669670
return self
670671

@@ -744,8 +745,13 @@ def clean_submission(self):
744745
self.process_form_data()
745746
self.ensure_user_has_account()
746747
# pass current submission data to avoid file save on every submit(if file is not updated)
747-
current_submission = ApplicationSubmission.objects.get(id=self.id)
748-
self.process_file_data(self.form_data, current_submission.from_draft().raw_data)
748+
if self.id:
749+
current_submission = ApplicationSubmission.objects.get(id=self.id)
750+
self.process_file_data(
751+
self.form_data, current_submission.from_draft().raw_data
752+
)
753+
else:
754+
self.process_file_data(self.form_data)
749755

750756
def get_assigned_meta_terms(self):
751757
"""Returns assigned meta terms excluding the 'root' term"""
@@ -797,7 +803,7 @@ def save(self, *args, update_fields=None, skip_custom=False, **kwargs):
797803
f"{self.get_from_parent('submission_id_prefix')}{self.id}"
798804
)
799805

800-
self.process_file_data(files, self.from_draft().raw_data)
806+
self.process_file_data(files)
801807
AssignedReviewers.objects.bulk_create_reviewers(
802808
list(self.get_from_parent("reviewers").all()),
803809
self,

0 commit comments

Comments
 (0)