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 %}