add approve need to request list
This commit is contained in:
parent
a195e0b6fc
commit
db61f35711
3 changed files with 61 additions and 1 deletions
|
|
@ -134,6 +134,52 @@ def request_list(request):
|
|||
except Exception:
|
||||
emergency_approved = False
|
||||
|
||||
# Get current step approval status
|
||||
current_step_approval_status = None
|
||||
if instance.current_step:
|
||||
try:
|
||||
current_step_instance = instance.step_instances.filter(step=instance.current_step).first()
|
||||
if current_step_instance:
|
||||
# Check if this step requires approvals
|
||||
required_roles = current_step_instance.required_roles()
|
||||
if required_roles:
|
||||
# Get approvals by role
|
||||
approvals_by_role = current_step_instance.approvals_by_role()
|
||||
|
||||
# Check for rejections
|
||||
latest_rejection = current_step_instance.get_latest_rejection()
|
||||
if latest_rejection and current_step_instance.status == 'rejected':
|
||||
role_name = latest_rejection.role.name if latest_rejection.role else 'نامشخص'
|
||||
current_step_approval_status = {
|
||||
'status': 'rejected',
|
||||
'role': role_name,
|
||||
'display': f'رد شده توسط {role_name}'
|
||||
}
|
||||
else:
|
||||
# Check approval status
|
||||
pending_roles = []
|
||||
approved_roles = []
|
||||
for role in required_roles:
|
||||
if approvals_by_role.get(role.id) == 'approved':
|
||||
approved_roles.append(role.name)
|
||||
else:
|
||||
pending_roles.append(role.name)
|
||||
|
||||
if pending_roles:
|
||||
current_step_approval_status = {
|
||||
'status': 'pending',
|
||||
'roles': pending_roles,
|
||||
'display': f'در انتظار تایید {" و ".join(pending_roles)}'
|
||||
}
|
||||
elif approved_roles and not pending_roles:
|
||||
current_step_approval_status = {
|
||||
'status': 'approved',
|
||||
'roles': approved_roles,
|
||||
'display': f'تایید شده توسط {" و ".join(approved_roles)}'
|
||||
}
|
||||
except Exception:
|
||||
current_step_approval_status = None
|
||||
|
||||
instances_with_progress.append({
|
||||
'instance': instance,
|
||||
'progress_percentage': round(progress_percentage),
|
||||
|
|
@ -142,6 +188,7 @@ def request_list(request):
|
|||
'installation_scheduled_date': installation_scheduled_date,
|
||||
'installation_overdue_days': overdue_days,
|
||||
'emergency_approved': emergency_approved,
|
||||
'current_step_approval_status': current_step_approval_status,
|
||||
})
|
||||
|
||||
# Summary stats for header cards
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue