From c28c050d4017f2e0fb79cc61b42588cad455590e Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Wed, 20 Jun 2018 09:33:32 +0100 Subject: [PATCH] Make sure the restart stage cannot be used on accepted/rejected submissions --- opentech/apply/funds/models.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 8b43dbcf5..e2e95fceb 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -602,14 +602,28 @@ class ApplicationSubmission(WorkflowHelpers, BaseStreamForm, AbstractFormSubmiss def not_progressed(self): return not self.next + @property + def stage(self): + return self.phase.stage + + @property + def phase(self): + return self.workflow.get(self.status) + + @property + def active(self): + return self.status in active_statuses + @transition( status, source='*', target=RETURN_VALUE(INITIAL_STATE, 'draft_proposal', 'invited_to_proposal'), + conditions=[active], permission=make_permission_check({UserPermissions.ADMIN}), ) def restart_stage(self, **kwargs): """ If running form the console please include your user using the kwarg "by" + Will not reset applications which are accepted/rejected u = User.objects.get(email="<my@email.com>") for a in ApplicationSubmission.objects.all(): @@ -622,17 +636,6 @@ class ApplicationSubmission(WorkflowHelpers, BaseStreamForm, AbstractFormSubmiss return 'invited_to_proposal' return INITIAL_STATE - @property - def stage(self): - return self.phase.stage - - @property - def phase(self): - return self.workflow.get(self.status) - - @property - def active(self): - return self.status in active_statuses @property def last_edit(self): -- GitLab