fix: post summary taking more than one lines
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user