1

I have a flow like this:

    review_request = (
        flow.View(
            ReviewRequest,
        ).Permission(
            auto_create=True
        ).Next(this.check_response)
    )


    check_response = flow.If(cond=lambda act: True
        ).Then(
            this.approved_access_request
        ).Else(
            this.refused_access_request
        )


    approved_access_request = flow.View(
        AccessApproved,
    ).Assign(
        this.review_request.owner
    ).Permission(
        auto_create=True
    ).Next(this.end)

    refused_access_request = flow.View(
        AccessRefused,
    ).Assign(
        this.review_request.owner
    ).Permission(
        auto_create=True
    ).Next(this.end)

And a view:

class ReviewRequest(FlowMixin, generic.UpdateView):
    template_name = 'web/review-access-request.html'
    model = AccessRequest

    form_class = ReviewAccessRequestForm

    def get_object(self):
        return self.activation.process

    def request_details(self):
        return self.activation.process.access_request

    def form_valid(self, form):
        form.save()
        self.activation_done()
        next_view_url = self.get_success_url()
        return redirect(next_view_url)

The problem is the pages for AccessApproved and AccessRefused do not show. The assignment part works (shown by the admin material frontend), but the views are not executed. Instead there is a few second pause and the browser is send to the admin Inbox.

1 Answers1

2

View task is not executed automatically but picked by a user. Generally after flow.If the new assigned tasks available the in a user inbox.

If you press Save and Continue button in default frontend, your ReviewRequest view could decide where to go next, by calling viewflow.flow.utils.get_next_task_url

kmmbvnr
  • 5,863
  • 4
  • 35
  • 44
  • Thanks for the answer. I'm using custom views. Is there a way to show the next page in the flow automatically (wizard style), without the user going to the Inbox? I know I can do that from a view using `get_next_task_url`, but how about the flow itself (as I have a `flow.If` deciding what next step is)? – Access Denied Jan 09 '20 at 10:11
  • 1
    Redirect happens not by flow.If but in your view in get_success_url - https://github.com/viewflow/viewflow/blob/master/viewflow/flow/views/task.py#L31 – kmmbvnr Jan 10 '20 at 11:17