Exemple #1
0
 def put(self, request, pk, format=None):
     enrollment = self.get_object(pk)
     serializer = EnrollmentSerializer(enrollment, data=request.data, partial=True)
     if serializer.is_valid():
         serializer.save()
         return Response(status=status.HTTP_200_OK)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemple #2
0
 def post(self, request, format=None):
     serializer = EnrollmentSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemple #3
0
 def get(self, request, pk, format=None):
     enrollment = self.get_object(pk)
     enrollment = EnrollmentSerializer(enrollment)
     return Response(enrollment.data)
Exemple #4
0
 def get(self, request, crn, format=None):
     enrollments = Enrollment.objects.filter(crn=crn, is_active=True)
     serializer = EnrollmentSerializer(enrollments, many=True)
     return Response(serializer.data)
Exemple #5
0
 def get(self, request, format=None):
     enrollments = Enrollment.objects.all()
     serializer = EnrollmentSerializer(enrollments, many=True)
     return Response(serializer.data)
 def get_all_enrollments(self, obj):
     enrollments = Enrollment.objects.filter(user=obj)
     return EnrollmentSerializer(enrollments, many=True).data