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
6ea7c236
Commit
6ea7c236
authored
Nov 25, 2015
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-1593; include post in comment count
parent
996da3d7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
20 deletions
+35
-20
lms/djangoapps/discussion_api/serializers.py
+14
-2
lms/djangoapps/discussion_api/tests/test_api.py
+10
-10
lms/djangoapps/discussion_api/tests/test_serializers.py
+2
-2
lms/djangoapps/discussion_api/tests/test_views.py
+9
-6
No files found.
lms/djangoapps/discussion_api/serializers.py
View file @
6ea7c236
...
...
@@ -190,8 +190,8 @@ class ThreadSerializer(_ContentSerializer):
pinned
=
serializers
.
SerializerMethodField
(
read_only
=
True
)
closed
=
serializers
.
BooleanField
(
read_only
=
True
)
following
=
serializers
.
SerializerMethodField
()
comment_count
=
serializers
.
IntegerField
(
source
=
"comments_count"
,
read_only
=
True
)
unread_comment_count
=
serializers
.
IntegerField
(
source
=
"unread_comments_count"
,
read_only
=
True
)
comment_count
=
serializers
.
SerializerMethodField
(
read_only
=
True
)
unread_comment_count
=
serializers
.
SerializerMethodField
(
read_only
=
True
)
comment_list_url
=
serializers
.
SerializerMethodField
()
endorsed_comment_list_url
=
serializers
.
SerializerMethodField
()
non_endorsed_comment_list_url
=
serializers
.
SerializerMethodField
()
...
...
@@ -252,6 +252,18 @@ class ThreadSerializer(_ContentSerializer):
"""Returns the URL to retrieve the thread's non-endorsed comments."""
return
self
.
get_comment_list_url
(
obj
,
endorsed
=
False
)
def
get_comment_count
(
self
,
obj
):
"""Increments comment count to include post and returns total count of
contributions (i.e. post + responses + comments) for the thread"""
return
obj
[
"comments_count"
]
+
1
def
get_unread_comment_count
(
self
,
obj
):
"""Increments comment count to include post if thread is unread and returns
total count of unread contributions (i.e. post + responses + comments) for the thread"""
if
not
obj
[
"read"
]:
return
obj
[
"unread_comments_count"
]
+
1
return
obj
[
"unread_comments_count"
]
def
create
(
self
,
validated_data
):
thread
=
Thread
(
user_id
=
self
.
context
[
"cc_requester"
][
"id"
],
**
validated_data
)
thread
.
save
()
...
...
lms/djangoapps/discussion_api/tests/test_api.py
View file @
6ea7c236
...
...
@@ -644,7 +644,7 @@ class GetThreadListTest(CommentsServiceMockMixin, UrlResetMixin, SharedModuleSto
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
4
,
"comment_count"
:
5
,
"comment_count"
:
6
,
"unread_comment_count"
:
3
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread_id_0"
,
"endorsed_comment_list_url"
:
None
,
...
...
@@ -673,8 +673,8 @@ class GetThreadListTest(CommentsServiceMockMixin, UrlResetMixin, SharedModuleSto
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
9
,
"comment_count"
:
1
8
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
9
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
None
,
"endorsed_comment_list_url"
:
(
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread_id_1&endorsed=True"
...
...
@@ -1397,8 +1397,8 @@ class CreateThreadTest(
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
0
,
"comment_count"
:
0
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_id"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
@@ -1943,7 +1943,7 @@ class UpdateThreadTest(
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
0
,
"comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
0
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
...
...
@@ -2999,8 +2999,8 @@ class RetrieveThreadTest(
"pinned"
:
False
,
"closed"
:
False
,
"following"
:
False
,
"comment_count"
:
0
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
@@ -3039,8 +3039,8 @@ class RetrieveThreadTest(
"pinned"
:
False
,
"closed"
:
False
,
"following"
:
False
,
"comment_count"
:
0
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
lms/djangoapps/discussion_api/tests/test_serializers.py
View file @
6ea7c236
...
...
@@ -203,8 +203,8 @@ class ThreadSerializerSerializationTest(SerializerTestMixin, SharedModuleStoreTe
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
4
,
"comment_count"
:
5
,
"unread_comment_count"
:
3
,
"comment_count"
:
6
,
"unread_comment_count"
:
4
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
lms/djangoapps/discussion_api/tests/test_views.py
View file @
6ea7c236
...
...
@@ -296,8 +296,8 @@ class ThreadViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"abuse_flagged"
:
False
,
"voted"
:
True
,
"vote_count"
:
4
,
"comment_count"
:
5
,
"unread_comment_count"
:
3
,
"comment_count"
:
6
,
"unread_comment_count"
:
4
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
@@ -519,8 +519,8 @@ class ThreadViewSetCreateTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"abuse_flagged"
:
False
,
"voted"
:
False
,
"vote_count"
:
0
,
"comment_count"
:
0
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
@@ -634,6 +634,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
],
"created_at"
:
"Test Created Date"
,
"updated_at"
:
"Test Updated Date"
,
"comment_count"
:
1
,
})
)
self
.
assertEqual
(
...
...
@@ -684,6 +685,8 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
"closed"
:
True
,
"abuse_flagged"
:
value
,
"editable_fields"
:
[
"abuse_flagged"
,
"read"
],
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
})
)
...
...
@@ -1154,8 +1157,8 @@ class ThreadViewSetRetrieveTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase)
"pinned"
:
False
,
"closed"
:
False
,
"following"
:
False
,
"comment_count"
:
0
,
"unread_comment_count"
:
0
,
"comment_count"
:
1
,
"unread_comment_count"
:
1
,
"comment_list_url"
:
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread"
,
"endorsed_comment_list_url"
:
None
,
"non_endorsed_comment_list_url"
:
None
,
...
...
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