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( ...@@ -337,7 +337,7 @@ def get_thread_list(
return ret 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. Return the list of comments in the given thread.
...@@ -356,6 +356,8 @@ def get_comment_list(request, thread_id, endorsed, page, page_size): ...@@ -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 page_size: The number of comments to retrieve per page
mark_as_read: Marks the thread of the comment list as read.
Returns: Returns:
A paginated result containing a list of comments; see A paginated result containing a list of comments; see
...@@ -368,7 +370,7 @@ def get_comment_list(request, thread_id, endorsed, page, page_size): ...@@ -368,7 +370,7 @@ def get_comment_list(request, thread_id, endorsed, page, page_size):
retrieve_kwargs={ retrieve_kwargs={
"recursive": True, "recursive": True,
"user_id": request.user.id, "user_id": request.user.id,
"mark_as_read": True, "mark_as_read": mark_as_read,
"response_skip": response_skip, "response_skip": response_skip,
"response_limit": page_size, "response_limit": page_size,
} }
......
...@@ -121,6 +121,7 @@ class CommentListGetForm(_PaginationForm): ...@@ -121,6 +121,7 @@ class CommentListGetForm(_PaginationForm):
# TODO: should we use something better here? This only accepts "True", # TODO: should we use something better here? This only accepts "True",
# "False", "1", and "0" # "False", "1", and "0"
endorsed = NullBooleanField(required=False) endorsed = NullBooleanField(required=False)
mark_as_read = BooleanField(required=False)
class CommentActionsForm(Form): class CommentActionsForm(Form):
......
...@@ -1083,7 +1083,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase): ...@@ -1083,7 +1083,7 @@ class GetCommentListTest(CommentsServiceMockMixin, SharedModuleStoreTestCase):
{ {
"recursive": ["True"], "recursive": ["True"],
"user_id": [str(self.user.id)], "user_id": [str(self.user.id)],
"mark_as_read": ["True"], "mark_as_read": ["False"],
"resp_skip": ["70"], "resp_skip": ["70"],
"resp_limit": ["14"], "resp_limit": ["14"],
} }
......
...@@ -186,6 +186,7 @@ class CommentListGetFormTest(FormTestMixin, PaginationTestMixin, TestCase): ...@@ -186,6 +186,7 @@ class CommentListGetFormTest(FormTestMixin, PaginationTestMixin, TestCase):
"endorsed": False, "endorsed": False,
"page": 2, "page": 2,
"page_size": 13, "page_size": 13,
"mark_as_read": False
} }
) )
......
...@@ -698,7 +698,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): ...@@ -698,7 +698,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"resp_skip": ["0"], "resp_skip": ["0"],
"resp_limit": ["10"], "resp_limit": ["10"],
"user_id": [str(self.user.id)], "user_id": [str(self.user.id)],
"mark_as_read": ["True"], "mark_as_read": ["False"],
} }
) )
...@@ -732,7 +732,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): ...@@ -732,7 +732,7 @@ class CommentViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"resp_skip": ["68"], "resp_skip": ["68"],
"resp_limit": ["4"], "resp_limit": ["4"],
"user_id": [str(self.user.id)], "user_id": [str(self.user.id)],
"mark_as_read": ["True"], "mark_as_read": ["False"],
} }
) )
......
...@@ -314,6 +314,9 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet): ...@@ -314,6 +314,9 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
* page_size: The number of items per page (default is 10, max is 100) * 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**: **POST Parameters**:
* thread_id (required): The thread to post the comment in * thread_id (required): The thread to post the comment in
...@@ -404,7 +407,8 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet): ...@@ -404,7 +407,8 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
form.cleaned_data["thread_id"], form.cleaned_data["thread_id"],
form.cleaned_data["endorsed"], form.cleaned_data["endorsed"],
form.cleaned_data["page"], 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