Commit 2bbcb929 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add timestamp to UserActivities serializer


Signed-off-by: default avatarMatheus Miranda <matheusmirandalacerda@gmail.com>
parent 4fe14c02
......@@ -12,6 +12,8 @@ from courses.classroom.serializers import BasicClassroomSerializer
from discussion.models import Comment, Topic
from datetime import datetime
class UserActionsSerializer(serializers.Serializer):
verb = serializers.CharField(required=True, max_length=100)
action_object_id = serializers.IntegerField(required=False)
......@@ -39,10 +41,16 @@ class ActionSerializer(serializers.ModelSerializer):
action_object = GenericRelatedField(read_only=True)
verb = GenericRelatedField(read_only=True)
action_phrase = serializers.SerializerMethodField()
timestamp = serializers.SerializerMethodField()
class Meta:
model = Action
fields = ('actor', 'target', 'action_object', 'verb', 'action_phrase')
fields = ('actor', 'target', 'action_object', 'verb', 'action_phrase', 'timestamp')
def get_timestamp(self, obj):
timestamp_str = obj.timestamp.strftime('%d-%m-%Y %H:%M:%S')
date, hour = timestamp_str.split()
return date + ' às ' + hour
def get_object_type(self, obj):
if isinstance(obj, Classroom):
......
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