Example #1
0
 def list(self, request, *args, **kwargs):
     if not belongsToInstitution(request, getUserInstitution(request)):
         raise PermissionDenied(
             detail='User does not belong to the institution', code=None)
     if request.user.is_superuser:
         self.queryset = Teacher.objects.all()
     else:
         self.queryset = Teacher.objects.filter(
             institution=getUserInstitution(request))
     return super(TeacherViewSet, self).list(request, *args, **kwargs)
Example #2
0
 def list(self, request, *args, **kwargs):
     self.serializer_class = TeacherListSerializer
     if not belongsToInstitution(request, getUserInstitution(request)):
         raise PermissionDenied(
             detail='User does not belong to the institution', code=None)
     if request.user.is_superuser:
         self.queryset = applyUserFilters(request, Teacher)
     else:
         self.queryset = applyUserFilters(
             request, Teacher, institution=getUserInstitution(request))
     response = super(TeacherViewSet, self).list(request, *args, **kwargs)
     response = generateKeys(response, self.serializer_class)
     return response
Example #3
0
 def list(self, request, *args, **kwargs):
     if not belongsToInstitution(request, getUserInstitution(request)):
         raise PermissionDenied(
             detail='User does not belong to the institution', code=None)
     self.serializer_class = CourseListSerializer
     if request.user.is_superuser:
         self.queryset = Course.objects.all()
     else:
         self.queryset = Course.objects.filter(
             institution=getUserInstitution(request))
     response = super(CourseViewSet, self).list(request, *args, **kwargs)
     response = generateKeys(response, self.serializer_class)
     return response
Example #4
0
 def retrieve(self, request, *args, **kwargs):
     if not belongsToInstitution(request, self.get_object().institution):
         raise PermissionDenied(
             detail='User does not belong to the institution', code=None)
     return super(TeacherViewSet, self).retrieve(request, *args, **kwargs)