diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 07fe086f5fd2fb25cd0daed66f8005554d7510ef..11abacbb225ef32a07ce0c207de580674dd9762c 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -411,18 +411,27 @@ class UpdateReviewersView(DelegatedViewMixin, UpdateView): removed=removed, ) - if added and self.object.status == INITIAL_STATE: - # Automatically transition the submission to "Internal review". - action = self.object.workflow.stepped_phases[1][0].name - try: - self.object.perform_transition( - action, - self.request.user, - request=self.request, - notify=False, - ) - except (PermissionDenied, KeyError): - pass + if added: + # Automatic workflow actions. + action = None + if self.object.status == INITIAL_STATE: + # Automatically transition the application to "Internal review". + action = self.object.workflow.stepped_phases[1][0].name + elif self.object.status == 'proposal_discussion': + # Automatically transition the proposal to "Internal review". + action = 'proposal_internal_review' + + # If action is set run perform_transition(). + if action: + try: + self.object.perform_transition( + action, + self.request.user, + request=self.request, + notify=False, + ) + except (PermissionDenied, KeyError): + pass return response diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index c1ddbf9a6746454d6535b41e2b238f7959d28054..9cfb36c8ed8ac21cfbabddfa6cbe5be3cd6fb59a 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -12,6 +12,8 @@ Workflow -> Stage -> Phase -> Action Current limitations: * 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] +* Do not reorder without looking at workflow automations steps in form_valid() in +opentech/apply/funds/views.py and opentech/apply/review/views.py. """ diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index dfe1f18ccead3b3bf3e20bb3a472c4dcb84fa7ed..d9c9443b02561835433d851fcf052cca46a40946 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -113,22 +113,24 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView): related=self.object, ) + # Automatic workflow actions. submission_stepped_phases = self.submission.workflow.stepped_phases + action = None 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 - 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: - # Automatically transition the submission to "Ready for discussion". + # Automatically transition the application to "Ready for discussion". 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: self.submission.perform_transition( action,