Skip to content

Commit

Permalink
Merge pull request #414 from raccoongang/fix/issue#412
Browse files Browse the repository at this point in the history
fix(issue#412): Fixes issue #412 - AttributeError at /api/v0/courses/111/responses/ and /api/v0/courses/111/errors/
  • Loading branch information
cmltaWt0 authored Mar 29, 2017
2 parents 6882578 + 534d9e1 commit 1573aa4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mysite/api/v0/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from rest_framework import viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.generics import get_object_or_404

from ..serializers import ResponseSerializer, ErrorSerializer
from ..permissions import IsInstructor
Expand All @@ -15,9 +16,11 @@ class ResponseViewSet(viewsets.mixins.ListModelMixin, viewsets.GenericViewSet):
queryset = Response.objects.filter(kind='orct', unitLesson__order__isnull=False)
serializer_class = ResponseSerializer


def get_queryset(self):
course = get_object_or_404(Course, id=self.kwargs.get('course_id'))
self.check_object_permissions(
self.request, Course.objects.filter(id=self.kwargs.get('course_id')).first()
self.request, course
)
queryset = super(ResponseViewSet, self).get_queryset()
return queryset.filter(course__id=self.kwargs.get('course_id'))
Expand All @@ -33,8 +36,9 @@ class ErrorViewSet(viewsets.mixins.ListModelMixin, viewsets.GenericViewSet):
serializer_class = ErrorSerializer

def get_queryset(self):
course = get_object_or_404(Course, id=self.kwargs.get('course_id'))
self.check_object_permissions(
self.request, Course.objects.filter(id=self.kwargs.get('course_id')).first()
self.request, course
)
queryset = super(ErrorViewSet, self).get_queryset()
return queryset.filter(response__course__id=self.kwargs.get('course_id'))

0 comments on commit 1573aa4

Please sign in to comment.