Commit 18116eab authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Update endpoint for user actions

parent 8c4bbbcd
......@@ -122,6 +122,11 @@ class ActionSerializer(serializers.ModelSerializer):
return ' a unidade {} na etapa {} do curso {}'.format(obj.title, obj.lesson, obj.lesson.course)
return ''
def get_actor_name(self, actor):
if actor.name:
return actor.name.split()[0]
return actor.username
def get_action_phrase(self, obj):
verbs = {
'access': 'acessou',
......@@ -133,7 +138,7 @@ class ActionSerializer(serializers.ModelSerializer):
action_phrase = ''
action_phrase += obj.actor.name.split()[0]
action_phrase += self.get_actor_name(obj.actor)
action_phrase += (' {}'.format(verbs.get(obj.verb)))
if obj.action_object:
......@@ -181,4 +186,4 @@ class ActionSerializer(serializers.ModelSerializer):
course = 'do curso {}'.format(obj.action_object.lesson.course)
compl = {'atividade': unit, 'etapa': step, 'curso': course}
return compl
return ''
\ No newline at end of file
return ''
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