0

I am trying to flow through tasks pragmattically using custom viewswhich will be controlled by an api. I have figured out how to flow through a process if i pass in the a task object to a flow_function

task = Task.objects.get(id=task_id)
response = hello_world_approve(task, json=json, user=user)


@flow_func
def hello_world_approve(activation, **kwargs):

    activation.process.approved = True
    activation.process.save()

    activation.prepare()
    activation.done()
    return activation

However i would like to be able to get the current task from the process object instead, like so

process = HelloWorldFlow.process_class.objects.get(id=task_id)
task = process.get_current_task()

Is this the way i should be going about this and is it possible or is there another approach i am missing?

1 Answers1

1

It's available as activation.task

kmmbvnr
  • 5,863
  • 4
  • 35
  • 44
  • Doesnt the function wrapped with `@flow_func` require the task itself? so if i have the activation i would already have the task? – Vincent Yeadon Feb 06 '20 at 09:59