4👍
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<process_pk>\d+)/approve/(?P<task_pk>\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<process_pk>\d+)/approve/(?P<task_pk>\d+)/detail/', DetailTaskView.as_view(), {
'flow_class': MyFlow,
'flow_task': MyFlow.approve
}),
url('^(?P<process_pk>\d+)/approve/(?P<task_pk>\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