Separate normal task review from AQMM review
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
|
||||
<tr class="align-top hover:bg-slate-50/70">
|
||||
<td class="px-4 py-4 text-sm">
|
||||
<a href="/work/engagements/{{ task.subscription_id }}" class="font-semibold text-slate-900 hover:text-brand-700">{{ task.client_display }}</a>
|
||||
<a href="/partner/reviews/engagements/{{ task.subscription_id }}" class="font-semibold text-slate-900 hover:text-brand-700">{{ task.client_display }}</a>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ task.engagement_label }}</div>
|
||||
<div class="mt-1 text-[11px] text-slate-400">Engagement #{{ task.subscription_id }}</div>
|
||||
</td>
|
||||
@@ -157,7 +157,7 @@
|
||||
<div class="mt-1 text-xs text-slate-500">{% if task.internal_target_date %}Target {{ task.internal_target_date }}{% else %}No task target{% endif %}</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 text-right">
|
||||
<a href="/work/engagements/{{ task.subscription_id }}" class="inline-flex rounded-xl border border-slate-300 px-3 py-2 text-xs font-semibold text-slate-700 hover:bg-slate-50">Open Review</a>
|
||||
<a href="/partner/reviews/engagements/{{ task.subscription_id }}" class="inline-flex rounded-xl border border-slate-300 px-3 py-2 text-xs font-semibold text-slate-700 hover:bg-slate-50">Open Review</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
+33
-14
@@ -152,23 +152,40 @@ def _decorate_task(task: ClientServiceTaskInstance, today: date) -> ClientServic
|
||||
return task
|
||||
|
||||
|
||||
def _task_bucket(task: ClientServiceTaskInstance) -> str:
|
||||
def _task_bucket(task: ClientServiceTaskInstance, current_user) -> str:
|
||||
status = (task.status or "pending").strip().lower()
|
||||
if status == "blocked":
|
||||
subscription = getattr(task, "subscription", None)
|
||||
uid = int(getattr(current_user, "id", 0) or 0)
|
||||
is_engagement_partner = uid and uid == int(getattr(subscription, "assigned_partner_user_id", 0) or 0)
|
||||
is_review_partner = uid and uid == int(getattr(subscription, "review_partner_user_id", 0) or 0)
|
||||
|
||||
normal_role = (getattr(task, "normal_review_role", None) or "").strip().lower()
|
||||
normal_status = (getattr(task, "normal_review_status", None) or "not_required").strip().lower()
|
||||
normal_partner_review = (
|
||||
is_engagement_partner
|
||||
and getattr(task, "normal_review_required", False)
|
||||
and normal_role in {"partner", "manager_or_partner"}
|
||||
)
|
||||
aqmm_partner_review = is_engagement_partner and getattr(task, "aqmm_partner_review_required", False)
|
||||
aqmm_review_partner_review = is_review_partner and getattr(task, "aqmm_review_partner_required", False)
|
||||
|
||||
if status == "blocked" and getattr(task, "rework_status", "none") != "open":
|
||||
return "clarification_required"
|
||||
if status == "completed":
|
||||
if (
|
||||
(normal_partner_review and normal_status == "rework_required")
|
||||
or (aqmm_partner_review and getattr(task, "partner_review_status", "not_required") == "rework_required")
|
||||
or (aqmm_review_partner_review and getattr(task, "review_partner_review_status", "not_required") == "rework_required")
|
||||
or getattr(task, "rework_status", "none") == "open"
|
||||
):
|
||||
return "rework_sent"
|
||||
if (
|
||||
(normal_partner_review and normal_status == "pending")
|
||||
or (aqmm_partner_review and getattr(task, "partner_review_status", "not_required") == "pending")
|
||||
or (aqmm_review_partner_review and getattr(task, "review_partner_review_status", "not_required") == "pending")
|
||||
):
|
||||
return "pending_review"
|
||||
if status in CLOSED_TASK_STATUSES:
|
||||
return "completed"
|
||||
if status in {"rework", "rework_required"}:
|
||||
return "rework_sent"
|
||||
if status == "pending":
|
||||
has_partner_rework = any(
|
||||
(getattr(comment, "comment_type", "") or "").strip().lower() == "partner_review_note"
|
||||
and not getattr(comment, "is_deleted", False)
|
||||
for comment in getattr(task, "comments", [])
|
||||
)
|
||||
return "rework_sent" if has_partner_rework else "approved"
|
||||
return "approved"
|
||||
|
||||
|
||||
@@ -186,6 +203,7 @@ def build_partner_payload(db: Session, request: Request, current_user, *, q: str
|
||||
selectinload(ClientServiceTaskInstance.subscription).selectinload(ClientServiceSubscription.catalogue),
|
||||
selectinload(ClientServiceTaskInstance.subscription).selectinload(ClientServiceSubscription.assigned_manager),
|
||||
selectinload(ClientServiceTaskInstance.subscription).selectinload(ClientServiceSubscription.assigned_staff),
|
||||
selectinload(ClientServiceTaskInstance.subscription).selectinload(ClientServiceSubscription.review_partner),
|
||||
selectinload(ClientServiceTaskInstance.assigned_to),
|
||||
selectinload(ClientServiceTaskInstance.comments).selectinload(ServiceTaskComment.created_by),
|
||||
)
|
||||
@@ -227,7 +245,8 @@ def build_partner_payload(db: Session, request: Request, current_user, *, q: str
|
||||
summary["clients"].add(task.client_id)
|
||||
if getattr(task, "subscription_id", None):
|
||||
summary["engagements"].add(task.subscription_id)
|
||||
if status == "completed":
|
||||
bucket = _task_bucket(task, current_user)
|
||||
if bucket == "pending_review":
|
||||
summary["pending_review"] += 1
|
||||
if status == "blocked":
|
||||
summary["blocked"] += 1
|
||||
@@ -237,7 +256,7 @@ def build_partner_payload(db: Session, request: Request, current_user, *, q: str
|
||||
summary["due_today"] += 1
|
||||
if status in CLOSED_TASK_STATUSES:
|
||||
summary["completed"] += 1
|
||||
lookup[_task_bucket(task)]["tasks"].append(task)
|
||||
lookup[bucket]["tasks"].append(task)
|
||||
|
||||
summary["clients"] = len(summary["clients"])
|
||||
summary["engagements"] = len(summary["engagements"])
|
||||
|
||||
Reference in New Issue
Block a user