flows: make FlowExecutor fully working without pending user

This commit is contained in:
Jens Langhammer 2020-05-10 15:28:52 +02:00
parent 4f785da452
commit fbc3ac6b30
1 changed files with 6 additions and 3 deletions

View File

@ -9,7 +9,7 @@ from structlog import get_logger
from passbook.core.views.utils import PermissionDeniedView from passbook.core.views.utils import PermissionDeniedView
from passbook.flows.exceptions import EmptyFlowException, FlowNonApplicableException from passbook.flows.exceptions import EmptyFlowException, FlowNonApplicableException
from passbook.flows.models import Flow, FlowDesignation, Stage from passbook.flows.models import Flow, FlowDesignation, Stage
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan, FlowPlanner from passbook.flows.planner import FlowPlan, FlowPlanner
from passbook.lib.config import CONFIG from passbook.lib.config import CONFIG
from passbook.lib.utils.reflection import class_to_path, path_to_class from passbook.lib.utils.reflection import class_to_path, path_to_class
from passbook.lib.utils.urls import is_url_absolute, redirect_with_qs from passbook.lib.utils.urls import is_url_absolute, redirect_with_qs
@ -145,8 +145,8 @@ class FlowExecutorView(View):
# User passed all stages # User passed all stages
LOGGER.debug( LOGGER.debug(
"f(exec): User passed all stages", "f(exec): User passed all stages",
user=self.plan.context[PLAN_CONTEXT_PENDING_USER],
flow_slug=self.flow.slug, flow_slug=self.flow.slug,
context=self.plan.context,
) )
return self._flow_done() return self._flow_done()
@ -159,7 +159,8 @@ class FlowExecutorView(View):
def cancel(self): def cancel(self):
"""Cancel current execution and return a redirect""" """Cancel current execution and return a redirect"""
del self.request.session[SESSION_KEY_PLAN] if SESSION_KEY_PLAN in self.request.session:
del self.request.session[SESSION_KEY_PLAN]
class FlowPermissionDeniedView(PermissionDeniedView): class FlowPermissionDeniedView(PermissionDeniedView):
@ -172,6 +173,8 @@ class ToDefaultFlow(View):
designation: Optional[FlowDesignation] = None designation: Optional[FlowDesignation] = None
def dispatch(self, request: HttpRequest) -> HttpResponse: def dispatch(self, request: HttpRequest) -> HttpResponse:
if SESSION_KEY_PLAN in self.request.session:
del self.request.session[SESSION_KEY_PLAN]
flow = get_object_or_404(Flow, designation=self.designation) flow = get_object_or_404(Flow, designation=self.designation)
# TODO: Get Flow depending on subdomain? # TODO: Get Flow depending on subdomain?
return redirect_with_qs( return redirect_with_qs(