Search code examples
djangodjango-viewflow

django viewflow - StartFunction not assigning task owner info


Followed the answer provided to How to create a django ViewFlow process programmatically

However it is not assigning (or persisting) owner info in the activation record.

@flow_start_view
def start_process(request):
    request.activation.prepare(request.POST or None,)
    request.activation.flow_task.owner = request.user
    request.activation.flow_task.task_title = "Start Process"

Also tried below and it is resulting in an error "'ManagedStartViewActivation' object has no attribute 'assign'"

 @flow_start_view
 def start_process(request):
     request.activation.prepare(request.POST or None,)
     request.activation.assign(request.user)
     request.activation.flow_task.task_title = "Start Process"

Solution

  • That's hard to understand what's you are going to achieve with that. @start_flow_view is the decorator for the Django view.That means that process started manually by a user through the browser.

    StartActivation class has ho assign method.

    http://docs.viewflow.io/viewflow_core_activation.html#viewflow.activation.StartActivation

    To assign a task means preventing an existing task to be executed by another user. Start task instances does not exist in the database. Each new start view invocation creates new process instance started with new start task instance.

    If you need to track a user who performed a start task, you can directly initialize a start activation with a user instance

    self.activation.prepare(request.POST or None, user=request.user)
    

    Or just use viewflow StartFlowMixinfor your class based view.