From 3b7984438c5deb4fd448d13554783af9e5c96eac Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Fri, 20 Aug 2021 10:15:53 +0200
Subject: [PATCH] Sort determination block by updated_at decending so newest at
 top.

---
 hypha/apply/determinations/models.py                      | 8 ++++++--
 .../determinations/includes/determination_block.html      | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/hypha/apply/determinations/models.py b/hypha/apply/determinations/models.py
index faa8a69ba..237d0d73b 100644
--- a/hypha/apply/determinations/models.py
+++ b/hypha/apply/determinations/models.py
@@ -28,12 +28,16 @@ from .options import ACCEPTED, DETERMINATION_CHOICES, REJECTED
 
 
 class DeterminationQuerySet(models.QuerySet):
+    def staff(self):
+        # Designed to be used with a queryset related to submissions
+        return self.all().order_by('-updated_at')
+
     def active(self):
         # Designed to be used with a queryset related to submissions
-        return self.get(is_draft=True)
+        return self.get(is_draft=True).order_by('-updated_at')
 
     def submitted(self):
-        return self.filter(is_draft=False)
+        return self.filter(is_draft=False).order_by('-updated_at')
 
     def final(self):
         return self.submitted().filter(outcome__in=[ACCEPTED, REJECTED])
diff --git a/hypha/apply/determinations/templates/determinations/includes/determination_block.html b/hypha/apply/determinations/templates/determinations/includes/determination_block.html
index 26da899c4..4987a0a53 100644
--- a/hypha/apply/determinations/templates/determinations/includes/determination_block.html
+++ b/hypha/apply/determinations/templates/determinations/includes/determination_block.html
@@ -1,7 +1,7 @@
 {% load humanize determination_tags %}
 <div class="sidebar__inner">
     <h5>Determinations</h5>
-    {% for determination in object.determinations.all %}
+    {% for determination in object.determinations.staff %}
         <p>
             <a class="link link--bold" href="{% url 'apply:submissions:determinations:detail' submission_pk=object.id pk=determination.id %}">
                 {% if determination.is_draft %}[Draft] {% endif %}{{ determination.get_outcome_display }}
-- 
GitLab