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

Merge pull request #1673 from OpenTechFund/fix/review-automatic-workflow-actions

Fix to Automatic workflow actions after creating seperate view for re…
parents fb8b7037 f3822e92
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,10 @@ class ReviewEditView(UserPassesTestMixin, BaseStreamForm, UpdateView): ...@@ -96,6 +96,10 @@ class ReviewEditView(UserPassesTestMixin, BaseStreamForm, UpdateView):
related=review, related=review,
) )
response = super().form_valid(form) response = super().form_valid(form)
# Automatic workflow actions.
review_workflow_actions(self.request, review.submission)
return response return response
def get_success_url(self): def get_success_url(self):
...@@ -164,32 +168,7 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView): ...@@ -164,32 +168,7 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView):
) )
# Automatic workflow actions. # Automatic workflow actions.
submission_stepped_phases = self.submission.workflow.stepped_phases review_workflow_actions(self.request, self.submission)
action = None
if self.submission.status == INITIAL_STATE:
# Automatically transition the application to "Internal review".
action = submission_stepped_phases[1][0].name
elif self.submission.status == submission_stepped_phases[1][0].name and self.submission.reviews.count() > 1:
# 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.by_reviewers().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,
self.request.user,
request=self.request,
notify=False,
)
except (PermissionDenied, KeyError):
pass
return response return response
...@@ -197,6 +176,41 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView): ...@@ -197,6 +176,41 @@ class ReviewCreateOrUpdateView(BaseStreamForm, CreateOrUpdateView):
return self.submission.get_absolute_url() return self.submission.get_absolute_url()
def review_workflow_actions(request, submission):
submission_stepped_phases = submission.workflow.stepped_phases
action = None
if submission.status == INITIAL_STATE:
# Automatically transition the application to "Internal review".
action = submission_stepped_phases[1][0].name
elif submission.status == 'proposal_discussion':
# Automatically transition the proposal to "Internal review".
action = 'proposal_internal_review'
elif submission.status == submission_stepped_phases[1][0].name and submission.reviews.count() > 1:
# Automatically transition the application to "Ready for discussion".
action = submission_stepped_phases[2][0].name
elif submission.status == 'ext_external_review' and submission.reviews.by_reviewers().count() > 1:
# Automatically transition the application to "Ready for discussion".
action = 'ext_post_external_review_discussion'
elif submission.status == 'com_external_review' and submission.reviews.by_reviewers().count() > 1:
# Automatically transition the application to "Ready for discussion".
action = 'com_post_external_review_discussion'
elif submission.status == 'external_review' and submission.reviews.by_reviewers().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:
submission.perform_transition(
action,
request.user,
request=request,
notify=False,
)
except (PermissionDenied, KeyError):
pass
class ReviewDisplay(UserPassesTestMixin, DetailView): class ReviewDisplay(UserPassesTestMixin, DetailView):
model = Review model = Review
raise_exception = True raise_exception = True
......
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