Process Views outside viewflow.frontend

前端 未结 1 1533
灰色年华
灰色年华 2021-01-15 10:45

I want to integrate processes, starting them etc., outside of the standard viewflow.frontend. To do I have been trying to create a simple page where I can start

1条回答
  •  被撕碎了的回忆
    2021-01-15 11:24

    The Viewflow views need to be parametrized by flow_class and flow_task instance. So you can include a start view as following::

    url('^start/', CreateProcessView.as_view(), {
         'flow_class': MyFlow,
         'flow_task': MyFlow.start})
    

    To add a task view URL config, you need to use process_pk and task_pk parameters

    url('^(?P\d+)/approve/(?P\d+)/', ApproveView.as_view(), {
         'flow_class': MyFlow,
         'flow_task': MyFlow.approve
    })
    

    For each node, you also can enable detail, and various actions URLs, ex:

    url('^(?P\d+)/approve/(?P\d+)/detail/', DetailTaskView.as_view(), {
         'flow_class': MyFlow,
         'flow_task': MyFlow.approve
    }),
    url('^(?P\d+)/approve/(?P\d+)/cancel/', CancelTaskView.as_view(), {
         'flow_class': MyFlow,
         'flow_task': MyFlow.approve
    }),
    

    All of that's a big cumbersome.

    Recommended way

    You can just include Flow.instance.urls that contains all URLs collected and ready for inclusion into an URL config.

    url('^myflow', include(MyFlow.instance.urls, namespace='myflow'))
    

    And at the last, to enable task list views, you can put URL entries manually, ex

    url('^myflow/inbox/', TaskListView.as_view(), {
        'flow_class': MyFlow}, name="tasks")
    

    or just use as viewflow.flow.viewset.FlowViewSet class

    myflow_urls = FlowViewSet(MyFlow).urls
    
    urlpatterns = [
        url(r'^myflow/', include(myflow_urls, namespace='myflow'))
    ]
    

    This is the recommended way to include viewflow URLs into a django URL Config. To customize views used in that URL config, you can subclass the FlowViewSet class and provide views in the nodes definition, ex

    class MyFlow(Flow):
        start = flow.Start(detail_view_class=MyDetailTaskView)
    

    For the sample usage, you can checkout the Viewflow Custom UI cookbook example - https://github.com/viewflow/cookbook/tree/master/custom_ui

    0 讨论(0)
提交回复
热议问题