Django Viewflow: From where to send email to user on task assignment?

426 Views Asked by At

I need to email owner when task is assigned to them. I tried following ways:

  1. Assign accepts a callable function which should return task owner. We can send email in this callable function. But if you read source code, you will find that this callable method is called multiple times, by calc_owner function. Hence if we email user here, multiple emails will be send

  2. Create a new Node method like EmailUser and call it after Assign and before Next. But the issue is, it should also be thorough some callable like Assign for it to be called for each Process. But where to call this callable function

This seems like very general use-case, with a very difficult solution. Or am I missing something?

1

There are 1 best solutions below

3
On BEST ANSWER

This functionality could be achieved in a custom subclass of flow.View, with custom activation class, where you can extend create_task method:

https://github.com/viewflow/viewflow/blob/master/viewflow/flow/activation.py#L77

approve = (
    UserTask(view.MyView)
    .onCreateEmail(template='...', recipients=....)
    .onAutoAssignEmail(template='...')

)