diff --git a/db.sqlite3 b/db.sqlite3 index 4408b15..5a406d6 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/processes/templates/processes/request_list.html b/processes/templates/processes/request_list.html index eee1727..1ae210a 100644 --- a/processes/templates/processes/request_list.html +++ b/processes/templates/processes/request_list.html @@ -223,11 +223,24 @@ {{ item.instance.code }} {{ item.instance.process.name }} - + {% if item.instance.status == 'completed' %} {{ item.instance.current_step.name|default:"--" }} {% elif item.instance.current_step %} {{ item.instance.current_step.name }} + {% if item.current_step_approval_status %} +
+ + {% if item.current_step_approval_status.status == 'rejected' %} + + {% elif item.current_step_approval_status.status == 'approved' %} + + {% else %} + + {% endif %} + {{ item.current_step_approval_status.display }} + + {% endif %} {% else %} -- {% endif %} diff --git a/processes/views.py b/processes/views.py index 372c8e7..5bcb38c 100644 --- a/processes/views.py +++ b/processes/views.py @@ -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