From fc6a6e3cd45a44946b27c903cc60d9ba59dc1525 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 28 Sep 2018 12:40:03 +0100 Subject: [PATCH] Revert some changes so we avoid clash on the Phase keys --- opentech/apply/funds/models/submissions.py | 4 +++- opentech/apply/funds/workflow.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/opentech/apply/funds/models/submissions.py b/opentech/apply/funds/models/submissions.py index 6d7f9b446..646422bc0 100644 --- a/opentech/apply/funds/models/submissions.py +++ b/opentech/apply/funds/models/submissions.py @@ -402,7 +402,9 @@ class ApplicationSubmission( for phase in STAGE_CHANGE_ACTIONS: transition = self.get_transition(phase) if can_proceed(transition): - target = PHASES[phase].stage + # We convert to dict as not concerned about transitions from the first phase + # See note in workflow.py + target = dict(PHASES)[phase].stage if not target: raise ValueError('Incorrect State for transition') diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index e580c5808..b0e408b68 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -429,7 +429,9 @@ WORKFLOWS = { } -PHASES = dict(itertools.chain.from_iterable(workflow.items() for workflow in WORKFLOWS.values())) +# This is not a dictionary as the keys will clash for the first phase of each workflow +# We cannot find the transitions for the first stage in this instance +PHASES = list(itertools.chain.from_iterable(workflow.items() for workflow in WORKFLOWS.values())) def get_stage_change_actions(): @@ -449,12 +451,11 @@ STAGE_CHANGE_ACTIONS = get_stage_change_actions() STATUSES = defaultdict(set) -for key, value in PHASES.items(): +for key, value in PHASES: STATUSES[value.display_name].add(key) - active_statuses = [ - status for status in PHASES + status for status, _ in PHASES if 'accepted' not in status and 'rejected' not in status and 'invited' not in status ] @@ -462,7 +463,7 @@ active_statuses = [ def get_review_statuses(user=None): reviews = set() - for phase_name, phase in PHASES.items(): + for phase_name, phase in PHASES: if 'review' in phase_name and 'discussion' not in phase_name: if user is None: reviews.add(phase_name) @@ -473,7 +474,7 @@ def get_review_statuses(user=None): review_statuses = get_review_statuses() -DETERMINATION_PHASES = list(phase_name for phase_name in PHASES if '_discussion' in phase_name) +DETERMINATION_PHASES = list(phase_name for phase_name, _ in PHASES if '_discussion' in phase_name) DETERMINATION_RESPONSE_PHASES = [ 'post_review_discussion', 'concept_review_discussion', @@ -483,7 +484,7 @@ DETERMINATION_RESPONSE_PHASES = [ def get_determination_transitions(): transitions = {} - for phase_name, phase in PHASES.items(): + for phase_name, phase in PHASES: for transition_name in phase.transitions: if 'accepted' in transition_name: transitions[transition_name] = 'accepted' -- GitLab