From 692e8f7124dc8e37619c873039c96779aebd626b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Tue, 16 Aug 2022 22:03:47 +0200
Subject: [PATCH] Mark resolved constraint violations in list and improve
 sorting

This implements #148
---
 AKScheduling/api.py                                        | 2 +-
 .../admin/AKScheduling/constraint_violations.html          | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/AKScheduling/api.py b/AKScheduling/api.py
index 2e065b46..7e60c864 100644
--- a/AKScheduling/api.py
+++ b/AKScheduling/api.py
@@ -125,4 +125,4 @@ class ConstraintViolationsViewSet(EventSlugMixin, viewsets.ModelViewSet):
         return get_object_or_404(ConstraintViolation, pk=self.kwargs["pk"])
 
     def get_queryset(self):
-        return ConstraintViolation.objects.filter(event=self.event)
+        return ConstraintViolation.objects.filter(event=self.event).order_by('manually_resolved', '-type', '-timestamp')
diff --git a/AKScheduling/templates/admin/AKScheduling/constraint_violations.html b/AKScheduling/templates/admin/AKScheduling/constraint_violations.html
index c987f311..056eb4de 100644
--- a/AKScheduling/templates/admin/AKScheduling/constraint_violations.html
+++ b/AKScheduling/templates/admin/AKScheduling/constraint_violations.html
@@ -63,7 +63,11 @@
 
                                // Update violations table
                                for(let i=0;i<response.length;i++) {
-                                   table_html += "<tr><td>" + response[i].level_display + "</td><td>" + response[i].type_display + "</td><td>" + response[i].details + "</td><td class='nowrap'>" + response[i].timestamp_display + "</td><td><a href='" + response[i].edit_url + "'><i class='btn btn-primary fa fa-pen'></i></a></td></tr>";
+                                   if(response[i].manually_resolved)
+                                       table_html += '<tr class="text-muted"><td class="nowrap">{% fa5_icon "check" "fas" %}</td>';
+                                   else
+                                       table_html += '<tr><td></td>';
+                                   table_html += "<td>" + response[i].level_display + "</td><td>" + response[i].type_display + "</td><td>" + response[i].details + "</td><td class='nowrap'>" + response[i].timestamp_display + "</td><td><a href='" + response[i].edit_url + "'><i class='btn btn-primary fa fa-pen'></i></a></td></tr>";
                                }
                            }
                            else {
@@ -115,6 +119,7 @@
     <table class="table table-striped mt-4 mb-4">
         <thead>
             <tr>
+                <th></th>
                 <th>{% trans "Violation" %}</th>
                 <th>{% trans "Problem" %}</th>
                 <th>{% trans "Details" %}</th>
-- 
GitLab