From fbe61f6eec650d26fc0bc7d433cd7cf3bbd853ab Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 17 Mar 2022 19:51:56 +0000 Subject: [PATCH] Fix bug when last use doens't have a User --- apiserver/apiserver/api/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index fd89e38..7b12f17 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -776,9 +776,16 @@ class StatsViewSet(viewsets.ViewSet, List): except KeyError: track = False + if last_use.user: + username = last_use.user.username + first_name = last_use.user.member.preferred_name + else: + username = last_use.username + first_name = username.split('.')[0].title() + return Response(dict( - username=last_use.user.username, - first_name=last_use.user.member.preferred_name, + username=username, + first_name=first_name, track=track, session_time=session_time, last_use_time=last_use_time,