Add confirmation and summary
This commit is contained in:
parent
9b3973805e
commit
35799b7754
25 changed files with 1419 additions and 265 deletions
|
@ -2,6 +2,7 @@
|
|||
{% load static %}
|
||||
{% load processes_tags %}
|
||||
{% load humanize %}
|
||||
{% load accounts_tags %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'sidebars/admin.html' %}
|
||||
|
@ -79,7 +80,11 @@
|
|||
{% else %}<span></span>{% endif %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-primary" type="submit">تایید و پایان</button>
|
||||
{% if request.user|is_broker %}
|
||||
<button class="btn btn-primary" type="submit">تایید و پایان</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary" type="button" disabled>تایید و پایان</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,7 @@ from processes.models import ProcessInstance, StepInstance
|
|||
from invoices.models import Invoice
|
||||
from installations.models import InstallationReport
|
||||
from .models import CertificateTemplate, CertificateInstance
|
||||
from common.consts import UserRoles
|
||||
|
||||
from _helpers.jalali import Gregorian
|
||||
|
||||
|
@ -78,6 +79,14 @@ def certificate_step(request, instance_id, step_id):
|
|||
next_step = instance.process.steps.filter(order__gt=instance.current_step.order).first() if instance.current_step else None
|
||||
|
||||
if request.method == 'POST':
|
||||
# Only broker can approve and finish certificate step
|
||||
try:
|
||||
if not (hasattr(request.user, 'profile') and request.user.profile.has_role(UserRoles.BROKER)):
|
||||
messages.error(request, 'شما مجوز تایید این مرحله را ندارید')
|
||||
return redirect('processes:step_detail', instance_id=instance.id, step_id=step.id)
|
||||
except Exception:
|
||||
messages.error(request, 'شما مجوز تایید این مرحله را ندارید')
|
||||
return redirect('processes:step_detail', instance_id=instance.id, step_id=step.id)
|
||||
cert.approved = True
|
||||
cert.approved_at = timezone.now()
|
||||
cert.save()
|
||||
|
@ -89,7 +98,10 @@ def certificate_step(request, instance_id, step_id):
|
|||
instance.current_step = next_step
|
||||
instance.save()
|
||||
return redirect('processes:step_detail', instance_id=instance.id, step_id=next_step.id)
|
||||
return redirect('processes:request_list')
|
||||
# Mark the whole process instance as completed on the last step
|
||||
instance.status = 'completed'
|
||||
instance.save()
|
||||
return redirect('processes:instance_summary', instance_id=instance.id)
|
||||
|
||||
return render(request, 'certificates/step.html', {
|
||||
'instance': instance,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue