From 3ec381d86906230ca445cc2382645a3512c85ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Papoti?= Date: Mon, 4 Nov 2024 18:07:13 -0300 Subject: [PATCH] wip --- patchwork/templates/patchwork/submission.html | 5 ++-- patchwork/templatetags/user.py | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 patchwork/templatetags/user.py diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 72ce2345..7fd23c47 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -3,6 +3,7 @@ {% load humanize %} {% load syntax %} {% load person %} +{% load user %} {% load patch %} {% load static %} {% load utils %} @@ -194,9 +195,9 @@

Notes

- {{ note.patch.submitter|personify:project }} + User: {{ note.submitter|userfy }}, - Last modified: {{ note.last_modified }} UTC + Last modified: {{ note.updated_at }} UTC
diff --git a/patchwork/templatetags/user.py b/patchwork/templatetags/user.py
new file mode 100644
index 00000000..40c93367
--- /dev/null
+++ b/patchwork/templatetags/user.py
@@ -0,0 +1,23 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2024 Meta Platforms, Inc. and affiliates.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from django import template
+from django.utils.html import escape
+from django.utils.safestring import mark_safe
+
+
+register = template.Library()
+
+
+@register.filter
+def userfy(user):
+    if user.first_name and user.last_name:
+        linktext = escape(f'{user.first_name} {user.last_name}')
+    elif user.email:
+        linktext = escape(user.email)
+    else:
+        linktext = escape(user.username)
+
+    return mark_safe(linktext)