Commit 31b57699 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Fix action phrase creation

parent 1b37611c
......@@ -14,3 +14,4 @@ class CoursesStatsConfig(AppConfig):
registry.register('stats.AccessibleArea')
registry.register('discussion.Topic')
registry.register('discussion.Forum')
registry.register('courses_learning_objects.LearningObject')
......@@ -7,10 +7,12 @@ from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
User = get_user_model()
from courses.models import Course
from courses.classroom.models import Classroom
from courses.classroom.serializers import BasicClassroomSerializer
from discussion.models import Comment, Topic
from discussion.models import Comment, Topic, Forum
from courses_learning_objects.models import LearningObject
from datetime import datetime
......@@ -53,12 +55,16 @@ class ActionSerializer(serializers.ModelSerializer):
return date + ' às ' + hour
def get_object_type(self, obj):
if isinstance(obj, Course):
return ' no curso ' + obj.name
if isinstance(obj, Classroom):
return ' na sala '
if isinstance(obj, Comment):
return ' no comentário '
return ' na sala ' + obj.name
if isinstance(obj, Topic):
return ' no tópico '
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):
......@@ -66,7 +72,8 @@ class ActionSerializer(serializers.ModelSerializer):
'access': 'acessou',
'answered': 'respondeu',
'created': 'criou',
'reacted': 'reagiu'
'reacted': 'reagiu a',
'created comment': 'comentou'
}
action_phrase = ''
......@@ -74,9 +81,9 @@ class ActionSerializer(serializers.ModelSerializer):
action_phrase += obj.actor.name.split()[0]
action_phrase += (' ' + verbs.get(obj.verb))
if obj.target:
action_phrase += (self.get_object_type(obj.target) + str(obj.target))
if obj.action_object:
action_phrase += (self.get_object_type(obj.action_object) + str(obj.action_object))
action_phrase += self.get_object_type(obj.action_object)
if obj.target:
action_phrase += self.get_object_type(obj.target)
return action_phrase
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