From 3df21dfbe848a2430900bfa568952955e3f9673f Mon Sep 17 00:00:00 2001
From: sks444 <krishnasingh.ss30@gmail.com>
Date: Wed, 2 Dec 2020 15:41:42 +0530
Subject: [PATCH] Fix screening sorting on submission table

---
 hypha/apply/funds/tables.py                         | 10 +++++++++-
 hypha/apply/funds/templates/funds/tables/table.html |  4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py
index a3c2d589c..b306ef6db 100644
--- a/hypha/apply/funds/tables.py
+++ b/hypha/apply/funds/tables.py
@@ -131,7 +131,7 @@ class LabeledCheckboxColumn(tables.CheckBoxColumn):
 class BaseAdminSubmissionsTable(SubmissionsTable):
     lead = tables.Column(order_by=('lead.full_name',))
     reviews_stats = tables.TemplateColumn(template_name='funds/tables/column_reviews.html', verbose_name=mark_safe("Reviews<div>Assgn.\tComp.</div>"), orderable=False)
-    screening_status = tables.Column(verbose_name="Screening", accessor='joined_screening_statuses')
+    screening_status = tables.Column(verbose_name="Screening", accessor='screening_statuses')
 
     class Meta(SubmissionsTable.Meta):
         fields = ('title', 'phase', 'stage', 'fund', 'round', 'lead', 'submit_time', 'last_update', 'screening_status', 'reviews_stats')  # type: ignore
@@ -140,6 +140,14 @@ class BaseAdminSubmissionsTable(SubmissionsTable):
     def render_lead(self, value):
         return format_html('<span>{}</span>', value)
 
+    def render_screening_status(self, value):
+        try:
+            status = value.get(default=True).title
+        except ScreeningStatus.DoesNotExist:
+            return format_html('<span>{}</span>', 'Awaiting')
+        else:
+            return format_html('<span>{}</span>', status)
+
 
 class AdminSubmissionsTable(BaseAdminSubmissionsTable):
     """Adds admin only columns to the submissions table"""
diff --git a/hypha/apply/funds/templates/funds/tables/table.html b/hypha/apply/funds/templates/funds/tables/table.html
index 1a51c0527..c9d6eed8b 100644
--- a/hypha/apply/funds/templates/funds/tables/table.html
+++ b/hypha/apply/funds/templates/funds/tables/table.html
@@ -20,7 +20,7 @@
                     <tr class="submission-meta__row">
                         <th><h6 class="heading heading--normal heading--no-margin">Applicant</h6></th>
                         <th><h6 class="heading heading--normal heading--no-margin">Last updated</h6></th>
-                        <th><h6 class="heading heading--normal heading--no-margin">Screening status</h6></th>
+                        <th><h6 class="heading heading--normal heading--no-margin">Screening statuses</h6></th>
                         <th><h6 class="heading heading--normal heading--no-margin">Review outcomes</h6></th>
                     </tr>
                     <tr class="submission-meta__row submission-meta__row--black">
@@ -34,7 +34,7 @@
                             {% endif %}
                         </td>
                         <td>
-                            <strong>{% if object.screening_statuses.exists %}{{ object.screening_statuses|default:"Awaiting Screen status" }}{% endif %}</strong>
+                            <strong>{{ submission.joined_screening_statuses|default:"Awaiting" }}</strong>
                         </td>
 
                         <td>
-- 
GitLab