Пример #1
0
 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))
Пример #2
0
 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))
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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))
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 def test_not_enrolled(self):
     unenrolled_user = UserFactory.create()
     with self.assertRaises(Http404):
         get_course_topics(self.course.id, unenrolled_user)
Пример #10
0
 def test_nonexistent_course(self):
     with self.assertRaises(Http404):
         get_course_topics(CourseLocator.from_string("non/existent/course"), self.user)
Пример #11
0
 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)