FlowRuntimeError viewflow django
FlowRuntimeError viewflow django
这里真的需要你们的帮助!
我目前正在使用 viewflow 在 Django 项目上构建我的工作流程。我希望将 django-jsignature3 与 django-viewflow 集成,但是我在这样做时遇到了极大的困难。
viewflow 的文档真的很混乱,演示项目也没有真正的解释,所以如果我问的是一个愚蠢的问题,请耐心等待我。
错误码如下图
FlowRuntimeError
这是我的 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
这是我的代码:
flows.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
@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
})
删除后:
request.activation.prepare(request.POST or None, user=request.user)
错误变为:
No transition from ASSIGNED
错误回溯是:
raise TransitionNotAllowed('No transition from {0}'.format(current_state))
viewflow.fsm.TransitionNotAllowed: No transition from ASSIGNED
我不确定我在这里做错了什么,我怀疑这里是处理工作流程的签名部分的 views.py。但是我无法找出错误,有人可以帮我吗?
如果您使用自定义模板,您需要在 <form>
标签内包含 {{ activation.management_form }}
例如:https://github.com/viewflow/cookbook/blob/master/custom_ui/templates/parcel/delivery/task.html#L15
这里真的需要你们的帮助!
我目前正在使用 viewflow 在 Django 项目上构建我的工作流程。我希望将 django-jsignature3 与 django-viewflow 集成,但是我在这样做时遇到了极大的困难。
viewflow 的文档真的很混乱,演示项目也没有真正的解释,所以如果我问的是一个愚蠢的问题,请耐心等待我。
错误码如下图
FlowRuntimeError
这是我的 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
这是我的代码:
flows.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
@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
})
删除后:
request.activation.prepare(request.POST or None, user=request.user)
错误变为:
No transition from ASSIGNED
错误回溯是:
raise TransitionNotAllowed('No transition from {0}'.format(current_state))
viewflow.fsm.TransitionNotAllowed: No transition from ASSIGNED
我不确定我在这里做错了什么,我怀疑这里是处理工作流程的签名部分的 views.py。但是我无法找出错误,有人可以帮我吗?
如果您使用自定义模板,您需要在 <form>
标签内包含 {{ activation.management_form }}
例如:https://github.com/viewflow/cookbook/blob/master/custom_ui/templates/parcel/delivery/task.html#L15