feat: backend change for copy post functionality for discussions post (#30941)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
This commit is contained in:
committed by
GitHub
parent
d111be5375
commit
8c13fae0ff
@@ -110,6 +110,8 @@ def get_editable_fields(cc_content: Union[Thread, Comment], context: Dict) -> Se
|
||||
"pinned": is_thread and is_privileged,
|
||||
"read": is_thread,
|
||||
}
|
||||
if is_thread:
|
||||
editable_fields.update({"copy_link": True})
|
||||
|
||||
if is_thread_closed:
|
||||
# Return only editable fields
|
||||
|
||||
@@ -802,7 +802,7 @@ class GetThreadListTest(ForumsEnableMixin, CommentsServiceMockMixin, UrlResetMix
|
||||
"comment_count": 6,
|
||||
"unread_comment_count": 3,
|
||||
"comment_list_url": "http://testserver/api/discussion/v1/comments/?thread_id=test_thread_id_0",
|
||||
"editable_fields": ["abuse_flagged", "following", "read", "voted"],
|
||||
"editable_fields": ["abuse_flagged", "copy_link", "following", "read", "voted"],
|
||||
"has_endorsed": True,
|
||||
"read": True,
|
||||
"created_at": "2015-04-28T00:00:00Z",
|
||||
@@ -832,7 +832,7 @@ class GetThreadListTest(ForumsEnableMixin, CommentsServiceMockMixin, UrlResetMix
|
||||
"non_endorsed_comment_list_url": (
|
||||
"http://testserver/api/discussion/v1/comments/?thread_id=test_thread_id_1&endorsed=False"
|
||||
),
|
||||
"editable_fields": ["abuse_flagged", "following", "read", "voted"],
|
||||
"editable_fields": ["abuse_flagged", "copy_link", "following", "read", "voted"],
|
||||
"abuse_flagged_count": None,
|
||||
"can_delete": False,
|
||||
}),
|
||||
@@ -1893,6 +1893,7 @@ class CreateThreadTest(
|
||||
"anonymous",
|
||||
"close_reason_code",
|
||||
"closed",
|
||||
"copy_link",
|
||||
"edit_reason_code",
|
||||
"following",
|
||||
"pinned",
|
||||
@@ -3718,7 +3719,7 @@ class RetrieveThreadTest(
|
||||
self.request.user = non_author_user
|
||||
assert get_thread(self.request, self.thread_id) == self.expected_thread_data({
|
||||
'can_delete': False,
|
||||
'editable_fields': ['abuse_flagged', 'following', 'read', 'voted'],
|
||||
'editable_fields': ['abuse_flagged', 'copy_link', 'following', 'read', 'voted'],
|
||||
'unread_comment_count': 1
|
||||
})
|
||||
assert httpretty.last_request().method == 'GET'
|
||||
|
||||
@@ -63,7 +63,8 @@ class GetInitializableFieldsTest(ModuleStoreTestCase):
|
||||
)
|
||||
actual = get_initializable_thread_fields(context)
|
||||
expected = {
|
||||
"abuse_flagged", "course_id", "following", "raw_body", "read", "title", "topic_id", "type", "voted"
|
||||
"abuse_flagged", "copy_link", "course_id", "following", "raw_body",
|
||||
"read", "title", "topic_id", "type", "voted"
|
||||
}
|
||||
if is_privileged:
|
||||
expected |= {"closed", "pinned", "close_reason_code", "edit_reason_code"}
|
||||
@@ -116,7 +117,7 @@ class GetEditableFieldsTest(ModuleStoreTestCase):
|
||||
allow_anonymous_to_peers=allow_anonymous_to_peers,
|
||||
)
|
||||
actual = get_editable_fields(thread, context)
|
||||
expected = {"abuse_flagged", "following", "read", "voted"}
|
||||
expected = {"abuse_flagged", "copy_link", "following", "read", "voted"}
|
||||
if is_privileged:
|
||||
expected |= {"closed", "pinned", "close_reason_code", "edit_reason_code"}
|
||||
if is_author or is_privileged:
|
||||
|
||||
@@ -186,7 +186,7 @@ class ThreadSerializerSerializationTest(SerializerTestMixin, SharedModuleStoreTe
|
||||
"comment_count": 6,
|
||||
"unread_comment_count": 3,
|
||||
"pinned": True,
|
||||
"editable_fields": ["abuse_flagged", "following", "read", "voted"],
|
||||
"editable_fields": ["abuse_flagged", "copy_link", "following", "read", "voted"],
|
||||
"abuse_flagged_count": None,
|
||||
})
|
||||
assert self.serialize(thread) == expected
|
||||
|
||||
@@ -929,7 +929,7 @@ class ThreadViewSetListTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase, Pro
|
||||
"unread_comment_count": 3,
|
||||
"voted": True,
|
||||
"author": self.author.username,
|
||||
"editable_fields": ["abuse_flagged", "following", "read", "voted"],
|
||||
"editable_fields": ["abuse_flagged", "copy_link", "following", "read", "voted"],
|
||||
"abuse_flagged_count": None,
|
||||
})]
|
||||
self.register_get_threads_response(source_threads, page=1, num_pages=2)
|
||||
@@ -1304,7 +1304,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
|
||||
'rendered_body': '<p>Edited body</p>',
|
||||
'preview_body': 'Edited body',
|
||||
'editable_fields': [
|
||||
'abuse_flagged', 'anonymous', 'following', 'raw_body', 'read',
|
||||
'abuse_flagged', 'anonymous', 'copy_link', 'following', 'raw_body', 'read',
|
||||
'title', 'topic_id', 'type', 'voted'
|
||||
],
|
||||
'created_at': 'Test Created Date',
|
||||
@@ -1357,7 +1357,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
|
||||
'read': True,
|
||||
'closed': True,
|
||||
'abuse_flagged': value,
|
||||
'editable_fields': ['abuse_flagged', 'read'],
|
||||
'editable_fields': ['abuse_flagged', 'copy_link', 'read'],
|
||||
'comment_count': 1, 'unread_comment_count': 0
|
||||
})
|
||||
|
||||
@@ -1388,7 +1388,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
|
||||
'comment_count': 1,
|
||||
'read': True,
|
||||
'editable_fields': [
|
||||
'abuse_flagged', 'anonymous', 'following', 'raw_body', 'read',
|
||||
'abuse_flagged', 'anonymous', 'copy_link', 'following', 'raw_body', 'read',
|
||||
'title', 'topic_id', 'type', 'voted'
|
||||
],
|
||||
'response_count': 2
|
||||
@@ -1415,7 +1415,7 @@ class ThreadViewSetPartialUpdateTest(DiscussionAPIViewTestMixin, ModuleStoreTest
|
||||
'comment_count': 1,
|
||||
'can_delete': False,
|
||||
'read': True,
|
||||
'editable_fields': ['abuse_flagged', 'following', 'read', 'voted'],
|
||||
'editable_fields': ['abuse_flagged', 'copy_link', 'following', 'read', 'voted'],
|
||||
'response_count': 2
|
||||
})
|
||||
|
||||
@@ -1493,7 +1493,7 @@ class LearnerThreadViewAPITest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
|
||||
{
|
||||
"key": "editable_fields",
|
||||
"value": [
|
||||
'abuse_flagged', 'anonymous', 'following', 'raw_body',
|
||||
'abuse_flagged', 'anonymous', 'copy_link', 'following', 'raw_body',
|
||||
'read', 'title', 'topic_id', 'type', 'voted'
|
||||
]
|
||||
},
|
||||
|
||||
@@ -470,6 +470,7 @@ class CommentsServiceMockMixin:
|
||||
"editable_fields": [
|
||||
"abuse_flagged",
|
||||
"anonymous",
|
||||
"copy_link",
|
||||
"following",
|
||||
"raw_body",
|
||||
"read",
|
||||
|
||||
Reference in New Issue
Block a user