add scope to filter data
This commit is contained in:
parent
394546dc67
commit
e9dec3292c
13 changed files with 386 additions and 36 deletions
|
@ -12,6 +12,7 @@ from .models import CertificateTemplate, CertificateInstance
|
|||
from common.consts import UserRoles
|
||||
|
||||
from _helpers.jalali import Gregorian
|
||||
from processes.utils import get_scoped_instance_or_404
|
||||
|
||||
|
||||
def _to_jalali(date_obj):
|
||||
|
@ -46,7 +47,7 @@ def _render_template(template: CertificateTemplate, instance: ProcessInstance):
|
|||
|
||||
@login_required
|
||||
def certificate_step(request, instance_id, step_id):
|
||||
instance = get_object_or_404(ProcessInstance, id=instance_id)
|
||||
instance = get_scoped_instance_or_404(request, instance_id)
|
||||
step = get_object_or_404(instance.process.steps, id=step_id)
|
||||
# Ensure all previous steps are completed and invoice settled
|
||||
prior_steps = instance.process.steps.filter(order__lt=instance.current_step.order if instance.current_step else 9999)
|
||||
|
@ -128,7 +129,7 @@ def certificate_step(request, instance_id, step_id):
|
|||
|
||||
@login_required
|
||||
def certificate_print(request, instance_id):
|
||||
instance = get_object_or_404(ProcessInstance, id=instance_id)
|
||||
instance = get_scoped_instance_or_404(request, instance_id)
|
||||
cert = CertificateInstance.objects.filter(process_instance=instance).order_by('-created').first()
|
||||
template = cert.template if cert else None
|
||||
return render(request, 'certificates/print.html', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue