Skip to content

Commit

Permalink
fixup! Do not depend on the text search for next transition
Browse files Browse the repository at this point in the history
  • Loading branch information
theskumar committed Nov 16, 2024
1 parent 4b5461a commit a3532e4
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions hypha/apply/funds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,33 +1380,13 @@ def form_valid(self, form: BaseModelForm) -> HttpResponse:
submitting_proposal = self.object.phase.name in STAGE_CHANGE_ACTIONS

if submitting_proposal:
transitions = self.object.get_available_user_status_transitions(
self.request.user
)
# Get the transition corresponding to the object's current phase name
transition = next(
(t for t in transitions if t.source == self.object.phase.name), None
messenger(
MESSAGES.PROPOSAL_SUBMITTED,
request=self.request,
user=self.request.user,
source=self.object,
)

if transition:
# Only notify for initial submission or drafts
notify = (
not (revision or submitting_proposal)
or self.object.status == DRAFT_STATE
)
self.object.perform_transition(
transition.target,
self.request.user,
request=self.request,
notify=notify,
)
messenger(
MESSAGES.PROPOSAL_SUBMITTED,
request=self.request,
user=self.request.user,
source=self.object,
)

elif revision and not self.object.status == DRAFT_STATE:
messenger(
MESSAGES.APPLICANT_EDIT,
Expand All @@ -1416,6 +1396,27 @@ def form_valid(self, form: BaseModelForm) -> HttpResponse:
related=revision,
)

# Get the transition corresponding to the object's current phase name
transitions = self.object.get_available_user_status_transitions(
self.request.user
)
transition = next(
(t for t in transitions if t.source == self.object.phase.name),
None,
)
if transition:
# Only notify for initial submission or drafts
notify = (
not (revision or submitting_proposal)
or self.object.status == DRAFT_STATE
)
self.object.perform_transition(
transition.target,
self.request.user,
request=self.request,
notify=notify,
)

# Required for django-file-form: delete temporary files for the new files
# uploaded while edit.
form.delete_temporary_files()
Expand Down

0 comments on commit a3532e4

Please sign in to comment.