Commit a8d937ce by Christopher Lee

Merge pull request #9278 from edx/clee/dapi-update-mark-as-read

Added optional mark_as_read field to comments in Discussion API
parents eafb0755 5b35ab36
......@@ -337,7 +337,7 @@ def get_thread_list(
return ret
def get_comment_list(request, thread_id, endorsed, page, page_size):
def get_comment_list(request, thread_id, endorsed, page, page_size, mark_as_read=False):
"""
Return the list of comments in the given thread.
......@@ -356,6 +356,8 @@ def get_comment_list(request, thread_id, endorsed, page, page_size):
page_size: The number of comments to retrieve per page
mark_as_read: Marks the thread of the comment list as read.
Returns:
A paginated result containing a list of comments; see
......@@ -368,7 +370,7 @@ def get_comment_list(request, thread_id, endorsed, page, page_size):
retrieve_kwargs={
"recursive": True,
"user_id": request.user.id,
"mark_as_read": True,
"mark_as_read": mark_as_read,
"response_skip": response_skip,
"response_limit": page_size,
}
......
......@@ -121,6 +121,7 @@ class CommentListGetForm(_PaginationForm):
# TODO: should we use something better here? This only accepts "True",
# "False", "1", and "0"
endorsed = NullBooleanField(required=False)
mark_as_read = BooleanField(required=False)
class CommentActionsForm(Form):
......
......@@ -1083,7 +1083,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase):
{
"recursive": ["True"],
"user_id": [str(self.user.id)],
"mark_as_read": ["True"],
"mark_as_read": ["False"],
"resp_skip": ["70"],
"resp_limit": ["14"],
}
......
......@@ -186,6 +186,7 @@ class CommentListGetFormTest(FormTestMixin, PaginationTestMixin, TestCase):
"endorsed": False,
"page": 2,
"page_size": 13,
"mark_as_read": False
}
)
......
......@@ -698,7 +698,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"resp_skip": ["0"],
"resp_limit": ["10"],
"user_id": [str(self.user.id)],
"mark_as_read": ["True"],
"mark_as_read": ["False"],
}
)
......@@ -732,7 +732,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"resp_skip": ["68"],
"resp_limit": ["4"],
"user_id": [str(self.user.id)],
"mark_as_read": ["True"],
"mark_as_read": ["False"],
}
)
......
......@@ -314,6 +314,9 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
* page_size: The number of items per page (default is 10, max is 100)
* mark_as_read: Will mark the thread of the comments as read. (default
is False)
**POST Parameters**:
* thread_id (required): The thread to post the comment in
......@@ -404,7 +407,8 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
form.cleaned_data["thread_id"],
form.cleaned_data["endorsed"],
form.cleaned_data["page"],
form.cleaned_data["page_size"]
form.cleaned_data["page_size"],
form.cleaned_data["mark_as_read"]
)
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment