Commit 4b58ca30 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add config for logging Card access

parent 1e1d94a1
......@@ -14,3 +14,4 @@ class CoursesStatsConfig(AppConfig):
registry.register('stats.AccessibleArea')
registry.register('discussion.Topic')
registry.register('discussion.Forum')
registry.register('cards.Card')
......@@ -14,6 +14,8 @@ from courses.classroom.serializers import BasicClassroomSerializer
from discussion.models import Comment, Topic, Forum
from cards.models import Card
from courses_learning_objects.models import LearningObject, Answer
from datetime import datetime
......@@ -65,8 +67,8 @@ class ActionSerializer(serializers.ModelSerializer):
date, hour = tz_str.strftime('%d-%m-%Y %H:%M:%S').split()
return '{} às {}'.format(date, hour)
def get_accesible_area_name(self, name):
accesible_areas = {
def get_accessible_area_name(self, name):
accessible_areas = {
'Dashboard': 'a Página Inicial',
'Chat Main Page': 'os Chats',
'Profile Page': 'a Página de perfil',
......@@ -75,25 +77,30 @@ class ActionSerializer(serializers.ModelSerializer):
'Courses': 'a Lista de Espaços Formativos',
'Messages': 'os Avisos',
'Forums': 'os Fóruns',
'Cards List': 'a Lista de Conteúdos'
}
return accesible_areas.get(name, name)
return accessible_areas.get(name, name)
def get_object_type(self, obj):
if isinstance(obj, Course):
return ' no curso ' + obj.name
return ' no curso {}'.format(obj.name)
if isinstance(obj, Classroom):
return ' na sala ' + obj.name
return ' na sala {}'.format(obj.name)
if isinstance(obj, Topic):
return ' no tópico ' + obj.title
return ' no tópico {}'.format(obj.title)
if isinstance(obj, Forum):
return ' no fórum ' + obj.title
return ' no fórum {}'.format(obj.title)
if isinstance(obj, AccessibleArea):
return ' ' + self.get_accesible_area_name(obj.name)
return ' {}'.format(self.get_accessible_area_name(obj.name))
if isinstance(obj, LearningObject):
unit = obj.unit.title
step = obj.unit.lesson.name
course = obj.unit.lesson.course.name
return ' a atividade {} na etapa {} do curso {}'.format(unit, step, course)
if isinstance(obj, Card):
title = obj.title
group_name = obj.groups.first().name
return ' o conteúdo {} na {}'.format(title, group_name)
return ''
def get_action_phrase(self, obj):
......@@ -108,7 +115,7 @@ class ActionSerializer(serializers.ModelSerializer):
action_phrase = ''
action_phrase += obj.actor.name.split()[0]
action_phrase += (' ' + verbs.get(obj.verb))
action_phrase += (' {}'.format(verbs.get(obj.verb)))
if obj.action_object:
action_phrase += self.get_object_type(obj.action_object)
......
......@@ -12,6 +12,10 @@ from .models import AccessibleArea
from ..models import Course
from ..classroom.models import Classroom
from cards.models import Card
from courses_learning_objects.models import LearningObject
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
......@@ -28,6 +32,9 @@ class UserActionsView(views.APIView):
'Classroom': Classroom,
'Topic': Topic,
'Forum': Forum,
'AccessibleArea': AccessibleArea,
'LearningObject': LearningObject,
'Card': Card,
}
# Validate incoming data
......
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