def get(self, request, course_id): """Implements the GET method as described in the class docstring.""" course_key = CourseLocator.from_string(course_id) course = get_course_with_access(request.user, 'load_forum', course_key) if not any([isinstance(tab, DiscussionTab) for tab in course.tabs]): raise Http404 return Response(get_course_topics(course, request.user))
def get(self, request, course_id): """Implements the GET method as described in the class docstring.""" course_key = CourseLocator.from_string(course_id) course = get_course_with_access(request.user, 'load_forum', course_key) if not any([isinstance(tab, DiscussionTab) for tab in course.tabs]): raise Http404 return Response(get_course_topics(course, request.user))
def get(self, request, course_id): """ Implements the GET method as described in the class docstring. """ course_key = CourseKey.from_string(course_id) topic_ids = self.request.GET.get('topic_id') with modulestore().bulk_operations(course_key): response = get_course_topics( request, course_key, set(topic_ids.strip(',').split(',')) if topic_ids else None, ) return Response(response)
def get(self, request, course_id): """ Implements the GET method as described in the class docstring. """ course_key = CourseKey.from_string(course_id) topic_ids = self.request.GET.get('topic_id') with modulestore().bulk_operations(course_key): response = get_course_topics( request, course_key, set(topic_ids.strip(',').split(',')) if topic_ids else None, ) return Response(response)
def get_course_topics(self, user=None): """ Get course topics for self.course, using the given user or self.user if not provided, and generating absolute URIs with a test scheme/host. """ return get_course_topics(self.course, user or self.user)
def get(self, request, course_id): """Implements the GET method as described in the class docstring.""" course_key = CourseLocator.from_string(course_id) return Response(get_course_topics(course_key, request.user))
def get(self, request, course_id): """Implements the GET method as described in the class docstring.""" course_key = CourseKey.from_string(course_id) with modulestore().bulk_operations(course_key): response = get_course_topics(request, course_key) return Response(response)
def get_course_topics(self, user=None): """ Get course topics for self.course, using the given user or self.user if not provided, and generating absolute URIs with a test scheme/host. """ return get_course_topics(self.course.id, user or self.user)
def test_not_enrolled(self): unenrolled_user = UserFactory.create() with self.assertRaises(Http404): get_course_topics(self.course.id, unenrolled_user)
def test_nonexistent_course(self): with self.assertRaises(Http404): get_course_topics(CourseLocator.from_string("non/existent/course"), self.user)
def get(self, request, course_id): """Implements the GET method as described in the class docstring.""" course_key = CourseKey.from_string(course_id) with modulestore().bulk_operations(course_key): response = get_course_topics(request, course_key) return Response(response)