Commit 677a0e87 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Update info for last access

parent 57748d6b
......@@ -145,12 +145,15 @@ class UserStatsSerializer(serializers.ModelSerializer):
def get_last_access(self, obj):
last_access_obj = obj.actor_actions.order_by('timestamp').filter(verb='access').last()
if last_access_obj:
timestamp = last_access_obj.timestamp if last_access_obj else obj.last_login
if timestamp:
from django.utils import timezone
tz_str = timezone.localtime(last_access_obj.timestamp)
tz_str = timezone.localtime(timestamp)
date, hour = tz_str.strftime('%d-%m-%Y %H:%M:%S').split()
return '{} às {}'.format(date, hour)
return ''
else:
return ''
def get_accesses_count(self, obj):
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