Commit f541597a authored by Glaucia S. Santos's avatar Glaucia S. Santos
Browse files

New endpoint for message counter

parent 7d4ab20a
......@@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model
from rest_framework import viewsets, mixins
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from rest_framework.decorators import list_route
from .models import (Course, CourseProfessor, ProfessorMessage, ProfessorMessageRead, Class)
from .serializers import (CourseSerializer, BasicCourseProfessorSerializer,
......@@ -148,6 +149,11 @@ class ProfessorMessageViewSet(viewsets.ModelViewSet):
queryset = queryset[:int(limit_to)]
return queryset.prefetch_related('classrooms', 'classes', 'users', 'groups',).select_related('course', 'professor')
@list_route(methods=['get'], permission_classes=[IsAssistantOrCoordinatorOrAdminOrRecipient])
def count_message(self, request):
messages = self.get_queryset()
return Response({'count': messages.count()})
class ProfessorGlobalMessageViewSet(ProfessorMessageViewSet):
......
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