django-viewflow get task assign url for the next step?

193 views Asked by At

I have a typical workflow like below:

Start -> Notify -> Task -> End

Within the Notify step which sends out an email to someone need to perform the task, I want to include the url that goes directly to the "Task" assign page, is it possible?

My problem is, during the Notify step I don't think the Task step has been created in database yet, so cannot generate the url.

UPDATE:

Thanks for the answer, posting the code to generate the assign url:

def handler(self, activation):
    process = activation.process
    path = reverse('viewflow:connect:new_request/flow/newrequest:{}__assign'.format(activation.flow_task.name), args=[process.pk, activation.task.pk])
1

There are 1 answers

0
kmmbvnr On BEST ANSWER

You could add it as flow.View(...).onCreate handler

class MyFlow(Flow):
    approve = flow.View(...).OnCreate(this.on_approve_created)

    def on_approve_created(self, activation):
        if activation.task.owner:
            send_mail(
                'View task assigned to you','Here is the message.',
                '[email protected]', [activation.task.owner.email]
             )