From 85980f232b918aefb34f08391a4a4d8c23479a3f Mon Sep 17 00:00:00 2001 From: ismail Date: Mon, 20 Jul 2026 22:23:35 +0300 Subject: [PATCH] feat(department): surface appreciations on the department dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per the workflow realignment, the point of appreciation is recognition — managers should see the appreciations their department received alongside other feedback. Adds an 'Appreciations Received' card (amber theme) after the Pending Actions section, showing the count and the 10 most recent SENT appreciations. The card only renders when the department has at least one appreciation. --- apps/organizations/ui_views.py | 25 ++++++++++++++++ .../organizations/department_detail.html | 29 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/apps/organizations/ui_views.py b/apps/organizations/ui_views.py index 9545608..b6c7e77 100644 --- a/apps/organizations/ui_views.py +++ b/apps/organizations/ui_views.py @@ -2326,9 +2326,34 @@ def department_detail(request, pk): .filter(Q(champion__isnull=False) | Q(manager__isnull=False)) .order_by("name") ), + # Appreciations received by this department (SENT = terminal/recognized). + # Surfaced so managers see recognition alongside other feedback. + "dept_appreciations": _dept_appreciations_qs(department), + "dept_appreciations_count": _dept_appreciations_count(department), } return render(request, "organizations/department_detail.html", context) + +def _dept_appreciations_qs(department): + """Recent SENT appreciations for the department detail dashboard.""" + from apps.appreciation.models import Appreciation, AppreciationStatus + return ( + Appreciation.objects.filter( + department=department, + status=AppreciationStatus.SENT, + ).select_related("sender", "category").order_by("-sent_at")[:10] + ) + + +def _dept_appreciations_count(department): + """Total SENT appreciations for the department detail dashboard.""" + from apps.appreciation.models import Appreciation, AppreciationStatus + return Appreciation.objects.filter( + department=department, + status=AppreciationStatus.SENT, + ).count() + + def _check_department_access(user, department): if user.is_px_admin(): return True diff --git a/templates/organizations/department_detail.html b/templates/organizations/department_detail.html index 72e94a9..c7cfa2d 100644 --- a/templates/organizations/department_detail.html +++ b/templates/organizations/department_detail.html @@ -239,6 +239,35 @@ {% endif %} + {% if dept_appreciations_count > 0 %} + +
+
+
+
+ +
+

{% trans "Appreciations Received" %}

+
+ {{ dept_appreciations_count }} +
+ +
+ {% endif %} + {% if can_respond and pending_routing_involvements %} {% for inv in pending_routing_involvements %}