From 33d31d41172ac2158d180cca386f6138f0dc7064 Mon Sep 17 00:00:00 2001
From: moson <moson@archlinux.org>
Date: Mon, 24 Jun 2024 16:35:21 +0200
Subject: [PATCH] style: Indicate deleted accounts on requests page

Show "(deleted)" on requests page for user accounts that were removed.

Fixes #505

Signed-off-by: moson <moson@archlinux.org>
---
 templates/requests.html |  7 +++++--
 test/test_requests.py   | 10 ++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/templates/requests.html b/templates/requests.html
index a6b2ae461..95e9f5e12 100644
--- a/templates/requests.html
+++ b/templates/requests.html
@@ -119,12 +119,15 @@
                             <td>
                                 {# Filed by #}
                                 {# If the record has an associated User, display a link to that user. #}
-                                {# Otherwise, display nothing (an empty column). #}
+                                {# Otherwise, display "(deleted)". #}
                                 {% if result.User %}
                                     <a href="/account/{{ result.User.Username }}">
                                         {{ result.User.Username }}
-                                    </a>&nbsp;
+                                    </a>
+                                {% else %}
+                                    <i>(deleted)</i>
                                 {% endif %}
+                                &nbsp;
                                 <a target="_blank" rel="noopener noreferrer" href="{{ result.ml_message_url() }}">
                                     (PRQ#{{ result.ID }})
                                 </a>
diff --git a/test/test_requests.py b/test/test_requests.py
index dd621cc5f..1e9cac656 100644
--- a/test/test_requests.py
+++ b/test/test_requests.py
@@ -834,6 +834,16 @@ def test_requests(
     rows = root.xpath('//table[@class="results"]/tbody/tr')
     assert len(rows) == 5  # There are five records left on the second page.
 
+    # Delete requesters user account and check output
+    with db.begin():
+        db.delete(requests[0].User)
+
+    with client as request:
+        request.cookies = cookies
+        resp = request.get("/requests")
+
+    assert "(deleted)" in resp.text
+
 
 def test_requests_with_filters(
     client: TestClient,
-- 
GitLab