【问题标题】:How to Assign a Task to a user in Django-Vieflow如何在 Django-Vieflow 中为用户分配任务
【发布时间】:2018-08-07 03:21:22
【问题描述】:
class HelloWorldFlow(Flow):
    process_class = HelloWorldProcess
    ######### Here I start the process where i enter some text

    start = (
        flow.Start(CreateProcessView, fields=["text"])
        .Permission(auto_create=True)
        .Next(this.approve)
    )

    ######### Here i update the process view with the user name which i obtained from "asignedto"- which consist of all the user in a drop down

    approve = (
        flow.View(UpdateProcessView, fields=["asignedto"])
        .Assign(lambda act: act.process.created_by)
        .Permission(auto_create=True)
        .Next(this.task_assign)
    )
    ######### Below is the code where i am facing difficulty i am not able to know how to pass the user name in the .Assign()
    ######### This one works .Assign(username="Debasish"), however i want to assign the user based on previous workflow which is approve, where i selected from the drop down
    ######### This one do not work .Assign(username=this.approve.owner)

    task_assign = (
        flow.View(AssignTaskView)
        .Assign(this.approve.owner)
        .Next(this.check_approve)
    )
    ######### Below this its working

    check_approve = (
        flow.If(lambda activation: activation.process.approved)
        .Then(this.send)
        .Else(this.end)
    )

    send = flow.Handler(this.send_hello_world_request).Next(this.end)

    end = flow.End()

    def send_hello_world_request(self, activation):
        print(activation.process.text)

【问题讨论】:

    标签: django django-viewflow


    【解决方案1】:

    BPMN 的优势之一是流程可追溯性。您无法实施不会保留流程决策的流程。这对于流程性能分析非常方便。

    BPMN 中的每个任务都是相互独立的,并且只能对流程数据执行决策。这为流程图提供了灵活性,并允许重新排列流程节点,因为它们之间只有数据存储依赖关系。


    所以,简短的回答 - 将用户存储在 Process 模型中并使用 .Assign(lambda act: act.process.granted_user_for_a_task)

    【讨论】:

    • 非常感谢您的语法和建议。它真的对我有用。
    猜你喜欢
    • 1970-01-01
    • 2021-07-04
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多