add approve need to request list
This commit is contained in:
parent
a195e0b6fc
commit
db61f35711
3 changed files with 61 additions and 1 deletions
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
|
@ -223,11 +223,24 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ item.instance.code }}</td>
|
<td>{{ item.instance.code }}</td>
|
||||||
<td>{{ item.instance.process.name }}</td>
|
<td>{{ item.instance.process.name }}</td>
|
||||||
<td class="text-primary">
|
<td>
|
||||||
{% if item.instance.status == 'completed' %}
|
{% if item.instance.status == 'completed' %}
|
||||||
<a href="{% url 'processes:instance_summary' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name|default:"--" }}</a>
|
<a href="{% url 'processes:instance_summary' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name|default:"--" }}</a>
|
||||||
{% elif item.instance.current_step %}
|
{% elif item.instance.current_step %}
|
||||||
<a href="{% url 'processes:instance_steps' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name }}</a>
|
<a href="{% url 'processes:instance_steps' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name }}</a>
|
||||||
|
{% if item.current_step_approval_status %}
|
||||||
|
<br>
|
||||||
|
<small class="{% if item.current_step_approval_status.status == 'rejected' %}text-danger{% elif item.current_step_approval_status.status == 'approved' %}text-success{% else %}text-warning{% endif %}">
|
||||||
|
{% if item.current_step_approval_status.status == 'rejected' %}
|
||||||
|
<i class="bx bx-x-circle"></i>
|
||||||
|
{% elif item.current_step_approval_status.status == 'approved' %}
|
||||||
|
<i class="bx bx-check-circle"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="bx bx-time"></i>
|
||||||
|
{% endif %}
|
||||||
|
{{ item.current_step_approval_status.display }}
|
||||||
|
</small>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
--
|
--
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,52 @@ def request_list(request):
|
||||||
except Exception:
|
except Exception:
|
||||||
emergency_approved = False
|
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({
|
instances_with_progress.append({
|
||||||
'instance': instance,
|
'instance': instance,
|
||||||
'progress_percentage': round(progress_percentage),
|
'progress_percentage': round(progress_percentage),
|
||||||
|
|
@ -142,6 +188,7 @@ def request_list(request):
|
||||||
'installation_scheduled_date': installation_scheduled_date,
|
'installation_scheduled_date': installation_scheduled_date,
|
||||||
'installation_overdue_days': overdue_days,
|
'installation_overdue_days': overdue_days,
|
||||||
'emergency_approved': emergency_approved,
|
'emergency_approved': emergency_approved,
|
||||||
|
'current_step_approval_status': current_step_approval_status,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Summary stats for header cards
|
# Summary stats for header cards
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue