From 7e9d7e5198f0d1aaea877cb49cd60624606e4d31 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 26 Sep 2020 14:13:10 +0200 Subject: [PATCH] flows: fix two stages being removed when reevaluate_marker was enabled --- passbook/flows/planner.py | 10 ++++------ passbook/flows/views.py | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/passbook/flows/planner.py b/passbook/flows/planner.py index a732cf9ad..a5b9812da 100644 --- a/passbook/flows/planner.py +++ b/passbook/flows/planner.py @@ -46,24 +46,22 @@ class FlowPlan: self.stages.append(stage) self.markers.append(marker or StageMarker()) - def next(self) -> Optional[Stage]: + def next(self, offset = 0) -> Optional[Stage]: """Return next pending stage from the bottom of the list""" if not self.has_stages: return None - stage = self.stages[0] - marker = self.markers[0] + stage = self.stages[offset] + marker = self.markers[offset] if marker.__class__ is not StageMarker: LOGGER.debug("f(plan_inst): stage has marker", stage=stage, marker=marker) marked_stage = marker.process(self, stage) if not marked_stage: LOGGER.debug("f(plan_inst): marker returned none, next stage", stage=stage) - self.stages.remove(stage) - self.markers.remove(marker) if not self.has_stages: return None # pylint: disable=not-callable - return self.next() + return self.next(offset + 1) return marked_stage def pop(self): diff --git a/passbook/flows/views.py b/passbook/flows/views.py index c666b3383..b35dc4f8a 100644 --- a/passbook/flows/views.py +++ b/passbook/flows/views.py @@ -157,10 +157,6 @@ class FlowExecutorView(View): stage_class=class_to_path(self.current_stage_view.__class__), flow_slug=self.flow.slug, ) - # We call plan.next here to check for re-evaluate markers - # this is important so we can save the result - # and we don't have to re-evaluate the policies each request - self.plan.next() self.plan.pop() self.request.session[SESSION_KEY_PLAN] = self.plan if self.plan.stages: