Commit eeb72dc7 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

fix bug for empty objects

parent bd17f5f0
...@@ -361,12 +361,18 @@ class UserAccessView(views.APIView): ...@@ -361,12 +361,18 @@ class UserAccessView(views.APIView):
last_login = '' last_login = ''
last_access = '' last_access = ''
last_completed_activity = ''
accesses_7_days = 0 accesses_7_days = 0
accesses_30_days = 0 accesses_30_days = 0
if actions: if actions:
last_access = self.format_date(actions.filter(verb='access').last().timestamp) last_access_obj = actions.filter(verb='access').last()
last_completed_activity = self.format_date(actions.filter(verb='answered').order_by('timestamp').last().timestamp) last_activity_obj = actions.filter(verb='answered').last()
if last_access_obj:
last_access = self.format_date(last_access_obj.timestamp)
if last_activity_obj:
last_completed_activity = self.format_date(last_completed_activity_obj.timestamp)
last_login = self.format_date(user.last_login) last_login = self.format_date(user.last_login)
time_delta = timezone.now() - timedelta(days=7) time_delta = timezone.now() - timedelta(days=7)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment