diff --git a/lms/djangoapps/discussion_api/api.py b/lms/djangoapps/discussion_api/api.py index 0b54ec0ccf..548a76c919 100644 --- a/lms/djangoapps/discussion_api/api.py +++ b/lms/djangoapps/discussion_api/api.py @@ -8,6 +8,7 @@ from urlparse import urlunparse from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse from django.http import Http404 +import itertools from rest_framework.exceptions import PermissionDenied @@ -378,7 +379,7 @@ def get_comment_list(request, thread_id, endorsed, page, page_size, mark_as_read request, thread_id, retrieve_kwargs={ - "recursive": True, + "recursive": False, "user_id": request.user.id, "mark_as_read": mark_as_read, "response_skip": response_skip, @@ -415,7 +416,7 @@ def get_comment_list(request, thread_id, endorsed, page, page_size, mark_as_read raise Http404 num_pages = (resp_total + page_size - 1) / page_size if resp_total else 1 - results = [CommentSerializer(response, remove_fields=["children"], context=context).data for response in responses] + results = [CommentSerializer(response, context=context).data for response in responses] return get_paginated_data(request, results, page, num_pages) @@ -740,9 +741,15 @@ def get_response_comments(request, comment_id, page, page_size): """ try: cc_comment = Comment(id=comment_id).retrieve() - cc_thread, context = _get_thread_and_context(request, cc_comment["thread_id"]) + cc_thread, context = _get_thread_and_context( + request, + cc_comment["thread_id"], + retrieve_kwargs={ + "recursive": True, + } + ) if cc_thread["thread_type"] == "question": - thread_responses = cc_thread["endorsed_responses"] + cc_thread["non_endorsed_responses"] + thread_responses = itertools.chain(cc_thread["endorsed_responses"], cc_thread["non_endorsed_responses"]) else: thread_responses = cc_thread["children"] response_comments = [] diff --git a/lms/djangoapps/discussion_api/tests/test_api.py b/lms/djangoapps/discussion_api/tests/test_api.py index ca14dfbec9..7b0568cf6d 100644 --- a/lms/djangoapps/discussion_api/tests/test_api.py +++ b/lms/djangoapps/discussion_api/tests/test_api.py @@ -1085,7 +1085,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase): self.assert_query_params_equal( httpretty.httpretty.latest_requests[-2], { - "recursive": ["True"], + "recursive": ["False"], "user_id": [str(self.user.id)], "mark_as_read": ["False"], "resp_skip": ["70"], @@ -1147,6 +1147,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase): "voted": False, "vote_count": 4, "editable_fields": ["abuse_flagged", "voted"], + "children": [], }, { "id": "test_comment_2", @@ -1166,6 +1167,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase): "voted": False, "vote_count": 7, "editable_fields": ["abuse_flagged", "voted"], + "children": [], }, ] actual_comments = self.get_comment_list( diff --git a/lms/djangoapps/discussion_api/tests/test_views.py b/lms/djangoapps/discussion_api/tests/test_views.py index 915cfc89ec..6f5f699827 100644 --- a/lms/djangoapps/discussion_api/tests/test_views.py +++ b/lms/djangoapps/discussion_api/tests/test_views.py @@ -681,6 +681,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): "voted": True, "vote_count": 4, "editable_fields": ["abuse_flagged", "voted"], + "children": [], }] self.register_get_thread_response({ "id": self.thread_id, @@ -704,7 +705,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): self.assert_query_params_equal( httpretty.httpretty.latest_requests[-2], { - "recursive": ["True"], + "recursive": ["False"], "resp_skip": ["0"], "resp_limit": ["10"], "user_id": [str(self.user.id)], @@ -738,7 +739,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): self.assert_query_params_equal( httpretty.httpretty.latest_requests[-2], { - "recursive": ["True"], + "recursive": ["False"], "resp_skip": ["68"], "resp_limit": ["4"], "user_id": [str(self.user.id)], @@ -1026,6 +1027,7 @@ class ThreadViewSetRetrieveTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase) @httpretty.activate +@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) class CommentViewSetRetrieveTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): """Tests for CommentViewSet Retrieve""" def setUp(self):