Skip to content

Commit b37da94

Browse files
authored
Merge pull request #1263 from OpenTechFund/feature/workflow-automations-proposal
Automatically update status on proposals when reviewers are added and…
2 parents a10e497 + 95e7b83 commit b37da94

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

opentech/apply/funds/views.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,27 @@ def form_valid(self, form):
411411
removed=removed,
412412
)
413413

414-
if added and self.object.status == INITIAL_STATE:
415-
# Automatically transition the submission to "Internal review".
416-
action = self.object.workflow.stepped_phases[1][0].name
417-
try:
418-
self.object.perform_transition(
419-
action,
420-
self.request.user,
421-
request=self.request,
422-
notify=False,
423-
)
424-
except (PermissionDenied, KeyError):
425-
pass
414+
if added:
415+
# Automatic workflow actions.
416+
action = None
417+
if self.object.status == INITIAL_STATE:
418+
# Automatically transition the application to "Internal review".
419+
action = self.object.workflow.stepped_phases[1][0].name
420+
elif self.object.status == 'proposal_discussion':
421+
# Automatically transition the proposal to "Internal review".
422+
action = 'proposal_internal_review'
423+
424+
# If action is set run perform_transition().
425+
if action:
426+
try:
427+
self.object.perform_transition(
428+
action,
429+
self.request.user,
430+
request=self.request,
431+
notify=False,
432+
)
433+
except (PermissionDenied, KeyError):
434+
pass
426435

427436
return response
428437

opentech/apply/funds/workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
Current limitations:
1313
* Changing the name of a phase will mean that any object which references it cannot progress. [will
1414
be fixed when streamfield, may require intermediate fix prior to launch]
15+
* Do not reorder without looking at workflow automations steps in form_valid() in
16+
opentech/apply/funds/views.py and opentech/apply/review/views.py.
1517
"""
1618

1719

opentech/apply/review/views.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,24 @@ def form_valid(self, form):
113113
related=self.object,
114114
)
115115

116+
# Automatic workflow actions.
116117
submission_stepped_phases = self.submission.workflow.stepped_phases
118+
action = None
117119
if self.submission.status == INITIAL_STATE:
118-
# Automatically transition the submission to "Internal review".
120+
# Automatically transition the application to "Internal review".
119121
action = submission_stepped_phases[1][0].name
120-
try:
121-
self.submission.perform_transition(
122-
action,
123-
self.request.user,
124-
request=self.request,
125-
notify=False,
126-
)
127-
except (PermissionDenied, KeyError):
128-
pass
129122
elif self.submission.status == submission_stepped_phases[1][0].name and self.submission.reviews.count() > 1:
130-
# Automatically transition the submission to "Ready for discussion".
123+
# Automatically transition the application to "Ready for discussion".
131124
action = submission_stepped_phases[2][0].name
125+
elif self.submission.status == 'proposal_discussion':
126+
# Automatically transition the proposal to "Internal review".
127+
action = 'proposal_internal_review'
128+
elif self.submission.status == 'external_review' and self.submission.reviews.count() > 1:
129+
# Automatically transition the proposal to "Ready for discussion".
130+
action = 'post_external_review_discussion'
131+
132+
# If action is set run perform_transition().
133+
if action:
132134
try:
133135
self.submission.perform_transition(
134136
action,

0 commit comments

Comments
 (0)