Add confirmation and summary
This commit is contained in:
		
							parent
							
								
									9b3973805e
								
							
						
					
					
						commit
						35799b7754
					
				
					 25 changed files with 1419 additions and 265 deletions
				
			
		| 
						 | 
				
			
			@ -357,7 +357,18 @@ def step_detail(request, instance_id, step_id):
 | 
			
		|||
        id=instance_id
 | 
			
		||||
    )
 | 
			
		||||
    step = get_object_or_404(instance.process.steps, id=step_id)
 | 
			
		||||
    # If the request is already completed, redirect to read-only summary page
 | 
			
		||||
    if instance.status == 'completed':
 | 
			
		||||
        return redirect('processes:instance_summary', instance_id=instance.id)
 | 
			
		||||
    
 | 
			
		||||
    # جلوگیری از پرش به مراحل آینده: فقط اجازه نمایش مرحله جاری یا مراحل تکمیلشده
 | 
			
		||||
    try:
 | 
			
		||||
        if instance.current_step and step.order > instance.current_step.order:
 | 
			
		||||
            messages.error(request, 'ابتدا مراحل قبلی را تکمیل کنید.')
 | 
			
		||||
            return redirect('processes:step_detail', instance_id=instance.id, step_id=instance.current_step.id)
 | 
			
		||||
    except Exception:
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    # بررسی دسترسی به مرحله
 | 
			
		||||
    if not instance.can_access_step(step):
 | 
			
		||||
        messages.error(request, 'شما به این مرحله دسترسی ندارید. ابتدا مراحل قبلی را تکمیل کنید.')
 | 
			
		||||
| 
						 | 
				
			
			@ -414,8 +425,43 @@ def instance_steps(request, instance_id):
 | 
			
		|||
            messages.error(request, 'هیچ مرحلهای برای این فرآیند تعریف نشده است.')
 | 
			
		||||
            return redirect('processes:request_list')
 | 
			
		||||
    
 | 
			
		||||
    # If completed, go to summary instead of steps
 | 
			
		||||
    if instance.status == 'completed':
 | 
			
		||||
        return redirect('processes:instance_summary', instance_id=instance.id)
 | 
			
		||||
    return redirect('processes:step_detail', instance_id=instance.id, step_id=instance.current_step.id)
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
def instance_summary(request, instance_id):
 | 
			
		||||
    """نمای خلاصهٔ فقطخواندنی برای درخواستهای تکمیلشده."""
 | 
			
		||||
    instance = get_object_or_404(ProcessInstance.objects.select_related('well', 'representative'), id=instance_id)
 | 
			
		||||
    # Only show for completed requests; otherwise route to steps
 | 
			
		||||
    if instance.status != 'completed':
 | 
			
		||||
        return redirect('processes:instance_steps', instance_id=instance.id)
 | 
			
		||||
 | 
			
		||||
    # Collect final invoice, payments, and certificate if any
 | 
			
		||||
    from invoices.models import Invoice
 | 
			
		||||
    from installations.models import InstallationReport
 | 
			
		||||
    from certificates.models import CertificateInstance
 | 
			
		||||
    invoice = Invoice.objects.filter(process_instance=instance).first()
 | 
			
		||||
    payments = invoice.payments.filter(is_deleted=False).all() if invoice else []
 | 
			
		||||
    latest_report = InstallationReport.objects.filter(assignment__process_instance=instance).order_by('-created').first()
 | 
			
		||||
    certificate = CertificateInstance.objects.filter(process_instance=instance).order_by('-created').first()
 | 
			
		||||
 | 
			
		||||
    # Build rows like final invoice step
 | 
			
		||||
    rows = []
 | 
			
		||||
    if invoice:
 | 
			
		||||
        items_qs = invoice.items.select_related('item').filter(is_deleted=False).all()
 | 
			
		||||
        rows = list(items_qs)
 | 
			
		||||
 | 
			
		||||
    return render(request, 'processes/instance_summary.html', {
 | 
			
		||||
        'instance': instance,
 | 
			
		||||
        'invoice': invoice,
 | 
			
		||||
        'payments': payments,
 | 
			
		||||
        'rows': rows,
 | 
			
		||||
        'latest_report': latest_report,
 | 
			
		||||
        'certificate': certificate,
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
def my_processes(request):
 | 
			
		||||
    """نمایش فرآیندهای کاربر"""
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue