Skip to content
Snippets Groups Projects
Unverified Commit b37da943 authored by Fredrik Jonsson's avatar Fredrik Jonsson Committed by GitHub
Browse files

Merge pull request #1263 from OpenTechFund/feature/workflow-automations-proposal

Automatically update status on proposals when reviewers are added and…
parents a10e497c 95e7b831
No related branches found
No related tags found
No related merge requests found
...@@ -411,18 +411,27 @@ class UpdateReviewersView(DelegatedViewMixin, UpdateView): ...@@ -411,18 +411,27 @@ class UpdateReviewersView(DelegatedViewMixin, UpdateView):
removed=removed, removed=removed,
) )
if added and self.object.status == INITIAL_STATE: if added:
# Automatically transition the submission to "Internal review". # Automatic workflow actions.
action = self.object.workflow.stepped_phases[1][0].name action = None
try: if self.object.status == INITIAL_STATE:
self.object.perform_transition( # Automatically transition the application to "Internal review".
action, action = self.object.workflow.stepped_phases[1][0].name
self.request.user, elif self.object.status == 'proposal_discussion':
request=self.request, # Automatically transition the proposal to "Internal review".
notify=False, action = 'proposal_internal_review'
)
except (PermissionDenied, KeyError): # If action is set run perform_transition().
pass if action:
try:
self.object.perform_transition(
action,
self.request.user,
request=self.request,
notify=False,
)
except (PermissionDenied, KeyError):
pass
return response return response
......
...@@ -12,6 +12,8 @@ Workflow -> Stage -> Phase -> Action ...@@ -12,6 +12,8 @@ Workflow -> Stage -> Phase -> Action
Current limitations: Current limitations:
* Changing the name of a phase will mean that any object which references it cannot progress. [will * Changing the name of a phase will mean that any object which references it cannot progress. [will
be fixed when streamfield, may require intermediate fix prior to launch] be fixed when streamfield, may require intermediate fix prior to launch]
* Do not reorder without looking at workflow automations steps in form_valid() in
opentech/apply/funds/views.py and opentech/apply/review/views.py.
""" """
......
...@@ -113,22 +113,24 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView): ...@@ -113,22 +113,24 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView):
related=self.object, related=self.object,
) )
# Automatic workflow actions.
submission_stepped_phases = self.submission.workflow.stepped_phases submission_stepped_phases = self.submission.workflow.stepped_phases
action = None
if self.submission.status == INITIAL_STATE: if self.submission.status == INITIAL_STATE:
# Automatically transition the submission to "Internal review". # Automatically transition the application to "Internal review".
action = submission_stepped_phases[1][0].name action = submission_stepped_phases[1][0].name
try:
self.submission.perform_transition(
action,
self.request.user,
request=self.request,
notify=False,
)
except (PermissionDenied, KeyError):
pass
elif self.submission.status == submission_stepped_phases[1][0].name and self.submission.reviews.count() > 1: elif self.submission.status == submission_stepped_phases[1][0].name and self.submission.reviews.count() > 1:
# Automatically transition the submission to "Ready for discussion". # Automatically transition the application to "Ready for discussion".
action = submission_stepped_phases[2][0].name action = submission_stepped_phases[2][0].name
elif self.submission.status == 'proposal_discussion':
# Automatically transition the proposal to "Internal review".
action = 'proposal_internal_review'
elif self.submission.status == 'external_review' and self.submission.reviews.count() > 1:
# Automatically transition the proposal to "Ready for discussion".
action = 'post_external_review_discussion'
# If action is set run perform_transition().
if action:
try: try:
self.submission.perform_transition( self.submission.perform_transition(
action, action,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment