From 224a0de784634c1ee5569e12a7f95d1e9bc1bb5f Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sat, 4 Dec 2021 01:16:14 -0800 Subject: [PATCH] fix(python): add logged in date field to account/show.html Signed-off-by: Kevin Morris --- aurweb/routers/accounts.py | 7 +++++++ templates/account/show.html | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/aurweb/routers/accounts.py b/aurweb/routers/accounts.py index fc25a7e8..8eecaa31 100644 --- a/aurweb/routers/accounts.py +++ b/aurweb/routers/accounts.py @@ -451,6 +451,13 @@ async def account(request: Request, username: str): k = user.PGPKey or str() context["pgp_key"] = " ".join([k[i:i + 4] for i in range(0, len(k), 4)]) + login_ts = None + session = db.query(models.Session).filter( + models.Session.UsersID == user.ID).first() + if session: + login_ts = user.session.LastUpdateTS + context["login_ts"] = login_ts + # Render the template. return render_template(request, "account/show.html", context) diff --git a/templates/account/show.html b/templates/account/show.html index 3e36faf0..c6a53f4a 100644 --- a/templates/account/show.html +++ b/templates/account/show.html @@ -61,7 +61,6 @@ }} {% endif %} - {{ "Active" if not user.Suspended else "Suspended" | tr }} {% trans %}Registration date{% endtrans %}: @@ -69,6 +68,13 @@ {{ user.RegistrationTS.strftime("%Y-%m-%d") }} + {% if login_ts %} + + {% trans %}Last Login{% endtrans %}: + {% set login_ds = login_ts | dt | as_timezone(timezone) %} + {{ login_ds.strftime("%Y-%m-%d") }} + + {% endif %} {% trans %}Links{% endtrans %}: