FlowRuntimeError viewflow django

315 Views Asked by At

Really need you guys help here!

Im currently using viewflow to construct my workflow on a django project. I wish to integrate django-jsignature3 with django-viewflow , however i have met with extreme difficulty in doing so.

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.

The error code is as shown below

FlowRuntimeError

Here is the error trace back on my 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

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
    })

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. However i am unable to pinpoint out the mistake , can someone help me out here?

1

There are 1 best solutions below

0
On BEST ANSWER

If you use custom template, you need to include {{ activation.management_form }} inside <form> tag

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