Django viewflow 扩展任务视图

Django viewflow extend task view

我正在尝试在一个应用程序中同时使用 django-viewflow and django-permission 的想法,其中会有一些复杂的权限规则。我理解 django-permission 工作方式的方式是向要应用权限规则的视图添加装饰器。

我已经设法通过扩展基本视图流视图并将 urls.py 指向扩展视图来在流程视图上工作。当我尝试按照相同的想法执行任务时,我遇到了下面列出的错误

type object 'CBVTask' has no attribute 'flow_class'

models.py

class CBVArticle(models.Model):
    created_by = models.ForeignKey(User)
    title = models.CharField(max_length=100)
    content = models.TextField()

class CBVArticleProcess(Process):
    article = models.ForeignKey(CBVArticle, blank=True, null=True)

class CBVTask(Task):

    class Meta:
        proxy = True

flow.py

class CBVArticleFlow(Flow):
    process_class = models.CBVArticleProcess
    task_class = models.CBVTask

    start = (
        flow.Start(views.ArticleCreate).Next(this.end)
    )

    end =flow.End()

urls.py

myflow_urls = FlowViewSet(CBVArticleFlow).urls  

urlpatterns = [
    url(r'^process/(?P<process_pk>\d+)/$', views.TestDetailProcessView.as_view(), kwargs = dict(flow_class=CBVArticleFlow), name='detail'),
    url(r'^process/(?P<process_pk>\d+)/start/(?P<task_pk>\d+)/detail/$', views.DetailTaskView.as_view(), kwargs = dict(flow_class=CBVArticleFlow, flow_task=CBVTask), name='start__detail'),
]

views.py

from viewflow.flow.views import DetailProcessView as BaseDetailProcessView, DetailTaskView as BaseDetailTaskView

@permission_required('test_app_cbv.view_cbvarticleprocess')
class TestDetailProcessView(BaseDetailProcessView):
    template_name = 'test_app_cbv/detail.html'

    def get_queryset(self):
        pk = self.kwargs['process_pk']

        return models.CBVArticleProcess.objects.filter(process_ptr_id = pk)

class DetailTaskView(BaseDetailTaskView):
    template_name = 'test_app_cbv/task_detail.html'

提前感谢您的指点!

事实证明这是一个新手错误 - urls.py 文件应该如下所示:

urls.py

myflow_urls = FlowViewSet(CBVArticleFlow).urls  

urlpatterns = [
    url(r'^process/(?P<process_pk>\d+)/$', views.TestDetailProcessView.as_view(), kwargs = dict(flow_class=CBVArticleFlow), name='detail'),
    url(r'^process/(?P<process_pk>\d+)/start/(?P<task_pk>\d+)/detail/$', views.DetailTaskView.as_view(), kwargs = dict(flow_class=CBVArticleFlow, flow_task=CBVArticleFlow.start), name='start__detail'),
]