Allow partners to execute tasks assigned to them

This commit is contained in:
A R R R Associates
2026-09-22 19:10:30 +05:30
parent 581f5faf80
commit b176f60c11
3 changed files with 130 additions and 3 deletions
+9 -1
View File
@@ -193,6 +193,11 @@ def _task_label(task: ClientServiceTaskInstance) -> dict[str, Any]:
catalogue = getattr(task, "catalogue", None)
assignee = getattr(task, "assigned_to", None)
status = (task.status or "pending").replace("_", " ").title()
status_code = (getattr(task, "status", None) or "pending").strip().lower()
is_locked = bool(getattr(task, "is_locked", False) or getattr(subscription, "is_locked", False))
is_task_assignee = int(getattr(task, "assigned_to_user_id", 0) or 0) == int(getattr(current_user, "id", 0) or 0)
can_execute = bool(is_task_assignee and not is_locked and status_code not in {"completed", "not_applicable"})
return {
"id": task.id,
"subscription_id": task.subscription_id,
@@ -543,10 +548,13 @@ def _partner_task_payload(task: ClientServiceTaskInstance, subscription: ClientS
"review_kind_label": "Normal Review" if review_level == "normal_partner" else ("AQMM Review Partner" if review_level == "review_partner" else ("AQMM Partner Review" if review_level == "partner" else "")),
"review_state": review_state,
"can_review": review_level is not None and review_state in {"pending_review", "reviewed", "rework"},
"is_task_assignee": is_task_assignee,
"can_execute": can_execute,
"execution_mode_label": "Assigned to you for execution" if can_execute else "",
"is_exception": getattr(task, "checklist_response", None) == "NO" or getattr(task, "rework_status", "none") == "open",
"evidence_count": len(documents),
"comments": comments,
"is_locked": bool(getattr(task, "is_locked", False) or getattr(subscription, "is_locked", False)),
"is_locked": is_locked,
}