简体   繁体   English

FlowRuntimeError 视图流 django

[英]FlowRuntimeError viewflow django

Really need you guys help here!在这里真的需要你们帮助!

Im currently using viewflow to construct my workflow on a django project.我目前使用 viewflow 在 django 项目上构建我的工作流程。 I wish to integrate django-jsignature3 with django-viewflow, however i have met with extreme difficulty in doing so.我希望将 django-jsignature3 与 django-viewflow 集成,但是我在这样做时遇到了极大的困难。

The documentations for viewflow is really confusing and the demo projects dont really have explanations so please be patient with me if what im asking is a dumb question. viewflow 的文档真的很混乱,演示项目并没有真正的解释,所以如果我问的是一个愚蠢的问题,请耐心等待我。

The error code is as shown below错误代码如下图

FlowRuntimeError

Here is the error trace back on my cmd:这是我的 cmd 上的错误跟踪:

    raise FlowRuntimeError('Activation metadata is broken {}'.format(self.management_form.errors))
viewflow.exceptions.FlowRuntimeError: Activation metadata is broken <ul class="errorlist"><li>started<ul class="errorlist"><li>This field is required.</li></ul></li></ul>
[04/Apr/2020 20:24:48] "POST /pipeline/20/approve1/57/ HTTP/1.1" 500 103532

Here is my code:这是我的代码:

flows.py流.py

class Pipeline(Flow):
process_class = PaymentVoucherProcess

start = flow.Start(
    CreateProcessView
).Permission(
    auto_create=True
).Next(this.approve1)

approve1 = flow.View(
    PreparerSignature,
).Next(this.check_approve1)

check_approve1 = flow.If(
    cond=lambda act: act.process.approved_preparer
).Then(this.approve2).Else(this.end)

approve2 = flow.View(
    VerifierSignature,
).Next(this.check_approve2)

check_approve2 = flow.If(
    cond=lambda act: act.process.approved_verifier
).Then(this.delivery).Else(this.end)

delivery = flow.View(
    UpdateProcessView,
    form_class=DropStatusForm
).Permission(
    auto_create=True
).Next(this.report)

report = flow.View(
    UpdateProcessView,
    fields=["remarks"]
).Next(this.end)

end = flow.End()

views.py视图.py

    @flow_view
def PreparerSignature(request, **kwargs):
    #this prepare statement might be the cause of the error
    request.activation.prepare(request.POST or None, user=request.user)
    form = PreparerSignatureForm(request.POST or None)
    if form.is_valid():
        esig = form.save(commit=False)
        signature = form.cleaned_data.get('signature')
        if signature:
            signature_picture = draw_signature(signature)
            signature_file_path = draw_signature(signature, as_file=True)
        esig.name = request.user
        esig.save()

        request.activation.process.approved_preparer = esig
        request.activation.done()

        return redirect(get_next_task_url(request, request.activation.process))

    return render(request, 'cash/pipeline/jsig.html', {
        'form': form,
        'activation': request.activation
    })

Upon removal of:删除后:

request.activation.prepare(request.POST or None, user=request.user)

The error becomes:错误变为:

No transition from ASSIGNED

and the error traceback is:错误回溯是:

 raise TransitionNotAllowed('No transition from {0}'.format(current_state))
viewflow.fsm.TransitionNotAllowed: No transition from ASSIGNED

I am unsure of what i am doing wrongly here, my suspect here is the views.py that handles the esignature portion of the work flow.我不确定我在这里做错了什么,我的怀疑是处理工作流程的签名部分的views.py。 However i am unable to pinpoint out the mistake, can someone help me out here?但是我无法查明错误,有人可以在这里帮助我吗?

If you use custom template, you need to include {{ activation.management_form }} inside <form> tag如果您使用自定义模板,则需要在<form>标签中包含{{ activation.management_form }}

ex: https://github.com/viewflow/cookbook/blob/master/custom_ui/templates/parcel/delivery/task.html#L15例如: https://github.com/viewflow/cookbook/blob/master/custom_ui/templates/parcel/delivery/task.html#L15

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM