Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c5afa44e
Commit
c5afa44e
authored
Oct 21, 2015
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
used recursive to optionally get response comments from comment service
parent
fa285e09
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
lms/djangoapps/discussion_api/api.py
+11
-4
lms/djangoapps/discussion_api/tests/test_api.py
+3
-1
lms/djangoapps/discussion_api/tests/test_views.py
+4
-2
No files found.
lms/djangoapps/discussion_api/api.py
View file @
c5afa44e
...
...
@@ -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"
:
Tru
e
,
"recursive"
:
Fals
e
,
"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
=
[]
...
...
lms/djangoapps/discussion_api/tests/test_api.py
View file @
c5afa44e
...
...
@@ -1085,7 +1085,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase):
self
.
assert_query_params_equal
(
httpretty
.
httpretty
.
latest_requests
[
-
2
],
{
"recursive"
:
[
"
Tru
e"
],
"recursive"
:
[
"
Fals
e"
],
"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
(
...
...
lms/djangoapps/discussion_api/tests/test_views.py
View file @
c5afa44e
...
...
@@ -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"
:
[
"
Tru
e"
],
"recursive"
:
[
"
Fals
e"
],
"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"
:
[
"
Tru
e"
],
"recursive"
:
[
"
Fals
e"
],
"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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment