From cf3969bc6c9988c100699f783fd6ba31e8af5f2a Mon Sep 17 00:00:00 2001 From: Zacho Date: Tue, 20 Feb 2024 21:43:49 +0100 Subject: [PATCH] Added Last Login to user/profile GUI views and the /users/user API output (#15198) * Added Last Login to user/profile GUI and user api output * Update netbox/templates/account/profile.html Co-authored-by: Jeremy Stretch * Update netbox/templates/account/profile.html Co-authored-by: Jeremy Stretch * Update netbox/templates/users/user.html Co-authored-by: Jeremy Stretch --------- Co-authored-by: Jeremy Stretch --- netbox/templates/account/profile.html | 4 ++++ netbox/templates/users/user.html | 4 ++++ netbox/users/api/serializers.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/netbox/templates/account/profile.html b/netbox/templates/account/profile.html index cb699072c..88e048f2f 100644 --- a/netbox/templates/account/profile.html +++ b/netbox/templates/account/profile.html @@ -34,6 +34,10 @@ {% trans "Account Created" %} {{ request.user.date_joined|annotated_date }} + + {% trans "Last Login" %} + {{ request.user.last_login|annotated_date }} + {% trans "Superuser" %} {% checkmark request.user.is_superuser %} diff --git a/netbox/templates/users/user.html b/netbox/templates/users/user.html index 18c07c1cc..a4d20131e 100644 --- a/netbox/templates/users/user.html +++ b/netbox/templates/users/user.html @@ -30,6 +30,10 @@ {% trans "Account Created" %} {{ object.date_joined|annotated_date }} + + {% trans "Last Login" %} + {{ object.last_login|annotated_date }} + {% trans "Active" %} {% checkmark object.is_active %} diff --git a/netbox/users/api/serializers.py b/netbox/users/api/serializers.py index c9775e39a..0a397d06f 100644 --- a/netbox/users/api/serializers.py +++ b/netbox/users/api/serializers.py @@ -35,7 +35,7 @@ class UserSerializer(ValidatedModelSerializer): model = get_user_model() fields = ( 'id', 'url', 'display', 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff', 'is_active', - 'date_joined', 'groups', + 'date_joined', 'last_login', 'groups', ) extra_kwargs = { 'password': {'write_only': True}