Commit 03f888b7 by wajeeha-khalid

MA-2663: Donot mark thread unread on any action but creation

parent a2bf4696
...@@ -916,6 +916,11 @@ def update_thread(request, thread_id, update_data): ...@@ -916,6 +916,11 @@ def update_thread(request, thread_id, update_data):
thread_edited.send(sender=None, user=request.user, post=cc_thread) thread_edited.send(sender=None, user=request.user, post=cc_thread)
api_thread = serializer.data api_thread = serializer.data
_do_extra_actions(api_thread, cc_thread, update_data.keys(), actions_form, context, request) _do_extra_actions(api_thread, cc_thread, update_data.keys(), actions_form, context, request)
# always return read as True (and therefore unread_comment_count=0) as reasonably
# accurate shortcut, rather than adding additional processing.
api_thread['read'] = True
api_thread['unread_comment_count'] = 0
return api_thread return api_thread
......
...@@ -2047,7 +2047,7 @@ class UpdateThreadTest( ...@@ -2047,7 +2047,7 @@ class UpdateThreadTest(
"endorsed_comment_list_url": None, "endorsed_comment_list_url": None,
"non_endorsed_comment_list_url": None, "non_endorsed_comment_list_url": None,
"editable_fields": ["abuse_flagged", "following", "raw_body", "read", "title", "topic_id", "type", "voted"], "editable_fields": ["abuse_flagged", "following", "raw_body", "read", "title", "topic_id", "type", "voted"],
'read': False, 'read': True,
'has_endorsed': False, 'has_endorsed': False,
'response_count': 0 'response_count': 0
} }
......
...@@ -833,7 +833,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest ...@@ -833,7 +833,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
def test_basic(self): def test_basic(self):
self.register_get_user_response(self.user) self.register_get_user_response(self.user)
self.register_thread({"created_at": "Test Created Date", "updated_at": "Test Updated Date"}) self.register_thread({"created_at": "Test Created Date", "updated_at": "Test Updated Date", "read": True})
request_data = {"raw_body": "Edited body"} request_data = {"raw_body": "Edited body"}
response = self.request_patch(request_data) response = self.request_patch(request_data)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
...@@ -849,6 +849,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest ...@@ -849,6 +849,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
"created_at": "Test Created Date", "created_at": "Test Created Date",
"updated_at": "Test Updated Date", "updated_at": "Test Updated Date",
"comment_count": 1, "comment_count": 1,
"read": True,
}) })
) )
self.assertEqual( self.assertEqual(
...@@ -864,7 +865,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest ...@@ -864,7 +865,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
"anonymous_to_peers": ["False"], "anonymous_to_peers": ["False"],
"closed": ["False"], "closed": ["False"],
"pinned": ["False"], "pinned": ["False"],
"read": ["False"], "read": ["True"],
} }
) )
......
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