From bfa916c7b294fb82f3b935f973b649f42849557b Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 3 Dec 2021 23:40:16 -0800 Subject: [PATCH] fix(fastapi): fix PGP Key Fingerprint display for account/show.html There's a space between every 4 characters in the fingerprint in PHP; we were missing it in FastAPI. This commit fixes that inconsistency. Signed-off-by: Kevin Morris --- aurweb/routers/accounts.py | 11 ++++++++++- templates/account/show.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/aurweb/routers/accounts.py b/aurweb/routers/accounts.py index f61ccdd2..946ffc31 100644 --- a/aurweb/routers/accounts.py +++ b/aurweb/routers/accounts.py @@ -432,7 +432,16 @@ async def account(request: Request, username: str): if not request.user.is_authenticated(): return render_template(request, "account/show.html", context, status_code=HTTPStatus.UNAUTHORIZED) - context["user"] = get_user_by_name(username) + + # Get related User record, if possible. + user = get_user_by_name(username) + context["user"] = user + + # Format PGPKey for display with a space between each 4 characters. + k = user.PGPKey or str() + context["pgp_key"] = " ".join([k[i:i + 4] for i in range(0, len(k), 4)]) + + # Render the template. return render_template(request, "account/show.html", context) diff --git a/templates/account/show.html b/templates/account/show.html index 0c99c99f..23b262b0 100644 --- a/templates/account/show.html +++ b/templates/account/show.html @@ -46,7 +46,7 @@ {% trans %}PGP Key Fingerprint{% endtrans %}: - {{ user.PGPKey or '' }} + {{ pgp_key }} {% trans %}Status{% endtrans %}: