fix: post summary taking more than one lines

This commit is contained in:
adeel.tajamul
2022-02-28 14:06:48 +05:00
parent 40bb23501a
commit 4af4a6a802
2 changed files with 2 additions and 2 deletions

View File

@@ -345,7 +345,7 @@ class ThreadSerializer(_ContentSerializer):
Returns a cleaned and truncated version of the thread's body to display in a
preview capacity.
"""
return Truncator(strip_tags(self.get_rendered_body(obj))).words(10, )
return Truncator(strip_tags(self.get_rendered_body(obj))).chars(35, ).replace('\n', ' ')
def create(self, validated_data):
thread = Thread(user_id=self.context["cc_requester"]["id"], **validated_data)

View File

@@ -1226,7 +1226,7 @@ class ThreadViewSetCreateTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
assert response_data == self.expected_thread_data({
"read": True,
"raw_body": "# Test \n This is a very long body that will be truncated for the preview.",
"preview_body": "Test This is a very long body that will be",
"preview_body": "Test This is a very long body that…",
"rendered_body": "<h1>Test</h1>\n<p>This is a very long body that will be truncated for the preview.</p>",
})
assert httpretty.last_request().parsed_body == { # lint-amnesty, pylint: disable=no-member