Commit 182016eb authored by Matheus Miranda's avatar Matheus Miranda
Browse files

format timestamp for last_access

parent c7ff8611
......@@ -144,10 +144,12 @@ class UserStatsSerializer(serializers.ModelSerializer):
'accesses_count', 'topics', 'reactions', 'comments')
def get_last_access(self, obj):
#group_id = self.context['group']
#group = Classroom.objects.get(id=group_id)
last_access_obj = obj.actor_actions.filter(verb='access').last()
return last_access_obj.timestamp if last_access_obj else ''
last_access_obj = obj.actor_actions.order_by('timestamp').filter(verb='access').last()
if last_access_obj:
timestamp_str = last_access_obj.timestamp.strftime('%d-%m-%Y %H:%M:%S')
date, hour = timestamp_str.split()
return date + ' às ' + hour
return ''
def get_accesses_count(self, obj):
time_delta = timezone.now() - timedelta(days=7)
......
......@@ -335,11 +335,6 @@ class UserStatsViewSet(viewsets.ReadOnlyModelViewSet):
'email'
]
def get_serializer_context(self):
return {
'group': self.request.query_params.get('group')
}
def get_queryset(self):
queryset = super().get_queryset()
group_id = self.request.query_params.get('group')
......
......@@ -14,4 +14,3 @@ class CoursesStatsConfig(AppConfig):
registry.register('stats.AccessibleArea')
registry.register('discussion.Topic')
registry.register('discussion.Forum')
registry.register('courses_learning_objects.LearningObject')
......@@ -12,7 +12,6 @@ from courses.classroom.models import Classroom
from courses.classroom.serializers import BasicClassroomSerializer
from discussion.models import Comment, Topic, Forum
from courses_learning_objects.models import LearningObject
from datetime import datetime
......@@ -63,8 +62,6 @@ class ActionSerializer(serializers.ModelSerializer):
return ' no tópico ' + obj.title
if isinstance(obj, Forum):
return ' no fórum ' + obj.title
if isinstance(obj, LearningObject):
return ' no fórum ' + obj.title
return ''
def get_action_phrase(self, obj):
......
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