Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
31b57699
Commit
31b57699
authored
Sep 28, 2020
by
Matheus Miranda
Browse files
Fix action phrase creation
parent
1b37611c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
courses/stats/apps.py
courses/stats/apps.py
+1
-0
courses/stats/serializers.py
courses/stats/serializers.py
+16
-9
No files found.
courses/stats/apps.py
View file @
31b57699
...
...
@@ -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'
)
courses/stats/serializers.py
View file @
31b57699
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment