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

New endpoint to list groups

parent f541597a
......@@ -12,12 +12,29 @@ from .serializers import (CourseSerializer, BasicCourseProfessorSerializer,
ProfessorMessageSerializer, ProfessorMessageReadSerializer,
from courses.workspaces.serializers import CourseGroupSerializer
from .permissions import (
class CourseGroupViewSet(viewsets.ModelViewSet):
model = Course
queryset = Course.objects.all()
serializer_class = CourseGroupSerializer
def get_queryset(self):
queryset = super(CourseGroupViewSet, self).get_queryset()
course = self.request.query_params.get('id', None)
if course:
queryset = queryset.filter(groups__id = course)
return queryset
class CourseViewSet(viewsets.ModelViewSet):
......@@ -86,3 +86,14 @@ class CourseGroupSerializer(serializers.ModelSerializer):
class Meta:
model = Course
fields = ('slug', 'name', 'groups')
def update(self, instance, validated_data):
data = self.context.get('request').data
course = super().update(instance, validated_data)
if 'groups' in data:
for g in data['groups']:
return course
\ No newline at end of file
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