From 3772846e552ed4d190ea4019a4352b8dd142866a Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 27 Apr 2026 22:05:30 +0100 Subject: [PATCH] feat: Update user messages inbox and collection user messages with enhanced acknowledgment statistics and navigation links --- .../atlas/collection_user_messages.html | 22 ++++++++++ .../templates/atlas/user_messages_inbox.html | 29 +++++++++++--- atlas/views.py | 40 ++++++++++++++++++- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/atlas/templates/atlas/collection_user_messages.html b/atlas/templates/atlas/collection_user_messages.html index cbeb0e5a..cf083cf3 100644 --- a/atlas/templates/atlas/collection_user_messages.html +++ b/atlas/templates/atlas/collection_user_messages.html @@ -45,6 +45,17 @@ {{ row.stats.outstanding_total_count }} outstanding
+
+
Pending acknowledgements
-
+
+ {{ total_needs_your_ack }} need your acknowledgement +
+
+ {{ total_waiting_on_other }} waiting on another user +
+
{{ total_outstanding }} unacknowledged message{{ total_outstanding|pluralize }}
@@ -38,11 +44,13 @@ {% endif %}
- {% if row.outstanding_count %} - {{ row.outstanding_count }} unacknowledged - {% else %} - No outstanding + + {{ row.needs_your_ack_count }} need your ack + + {% if row.waiting_on_other_count %} + {{ row.waiting_on_other_count }} waiting on other {% endif %} + {{ row.outstanding_count }} total unacknowledged Open user message page
@@ -59,7 +67,13 @@ {% if row.collection.show_title_post %} {{ case_row.casedetail.case.title|default:case_row.casedetail.case.pk|truncatechars:90 }} {% endif %} - {{ case_row.stats.outstanding_total_count }} unacknowledged + + {{ case_row.stats.needs_your_ack_count }} need your ack + + {% if case_row.stats.waiting_on_other_count %} + {{ case_row.stats.waiting_on_other_count }} waiting on other + {% endif %} + {{ case_row.stats.outstanding_total_count }} total {% if row.viewer_role == 'moderator' %}
@@ -114,6 +128,9 @@ : {{ case_row.casedetail.case.title|default:case_row.casedetail.case.pk|truncatechars:90 }} {% endif %} {{ case_row.stats.message_count }} messages + {% if case_row.stats.outstanding_total_count %} + {{ case_row.stats.outstanding_total_count }} unacknowledged + {% endif %}
diff --git a/atlas/views.py b/atlas/views.py index db17fd7c..d3c60d48 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -4500,6 +4500,8 @@ def user_messages_inbox(request): { "inbox_rows": [], "total_outstanding": 0, + "total_needs_your_ack": 0, + "total_waiting_on_other": 0, "show_all": request.GET.get("show") == "all", }, ) @@ -4537,12 +4539,23 @@ def user_messages_inbox(request): acknowledged_at__isnull=True, ), ), + outstanding_query_count=Count( + "id", + filter=Q( + requires_acknowledgement=True, + acknowledged_at__isnull=True, + message_type=CaseReviewMessage.MessageType.QUERY, + ), + ), ) ): outstanding_total_count = row["outstanding_total_count"] + outstanding_query_count = row["outstanding_query_count"] message_stats_by_attempt_case[row["cid_user_exam_id"]][row["case_id"]] = { "message_count": row["message_count"], "outstanding_total_count": outstanding_total_count, + "outstanding_query_count": outstanding_query_count, + "outstanding_feedback_count": outstanding_total_count - outstanding_query_count, "has_messages": row["message_count"] > 0, "has_outstanding_any": outstanding_total_count > 0, } @@ -4567,14 +4580,31 @@ def user_messages_inbox(request): { "message_count": 0, "outstanding_total_count": 0, + "outstanding_query_count": 0, + "outstanding_feedback_count": 0, "has_messages": False, "has_outstanding_any": False, }, ) + + outstanding_query_count = stats.get("outstanding_query_count", 0) + outstanding_feedback_count = stats.get("outstanding_feedback_count", 0) + if viewer_role == "moderator": + needs_your_ack_count = outstanding_query_count + waiting_on_other_count = outstanding_feedback_count + else: + needs_your_ack_count = outstanding_feedback_count + waiting_on_other_count = outstanding_query_count + + enriched_stats = { + **stats, + "needs_your_ack_count": needs_your_ack_count, + "waiting_on_other_count": waiting_on_other_count, + } feedback_rows.append( { "casedetail": casedetail, - "stats": stats, + "stats": enriched_stats, "thread_url": reverse( "atlas:collection_case_review_thread", kwargs={ @@ -4610,6 +4640,8 @@ def user_messages_inbox(request): ) outstanding_count = sum(row["stats"].get("outstanding_total_count", 0) for row in feedback_rows) + needs_your_ack_count = sum(row["stats"].get("needs_your_ack_count", 0) for row in feedback_rows) + waiting_on_other_count = sum(row["stats"].get("waiting_on_other_count", 0) for row in feedback_rows) inbox_rows.append( { "collection": collection, @@ -4620,6 +4652,8 @@ def user_messages_inbox(request): "outstanding_rows": outstanding_rows, "history_rows": history_rows, "outstanding_count": outstanding_count, + "needs_your_ack_count": needs_your_ack_count, + "waiting_on_other_count": waiting_on_other_count, } ) @@ -4633,6 +4667,8 @@ def user_messages_inbox(request): ) total_outstanding = sum(row["outstanding_count"] for row in inbox_rows) + total_needs_your_ack = sum(row["needs_your_ack_count"] for row in inbox_rows) + total_waiting_on_other = sum(row["waiting_on_other_count"] for row in inbox_rows) show_all = request.GET.get("show") == "all" return render( @@ -4641,6 +4677,8 @@ def user_messages_inbox(request): { "inbox_rows": inbox_rows, "total_outstanding": total_outstanding, + "total_needs_your_ack": total_needs_your_ack, + "total_waiting_on_other": total_waiting_on_other, "show_all": show_all, }, )