fix: fixed course update notification UI in notification tray (#35715)
This commit is contained in:
committed by
GitHub
parent
e8cdb06410
commit
ebe3dc5e12
@@ -974,3 +974,18 @@ class CourseUpdateNotificationTests(ModuleStoreTestCase):
|
||||
assert Notification.objects.all().count() == 1
|
||||
notification = Notification.objects.first()
|
||||
assert notification.content == "<p><strong>content Sub content heading</strong></p>"
|
||||
|
||||
def test_if_html_unescapes(self):
|
||||
"""
|
||||
Tests if html unescapes when creating content of course update notification
|
||||
"""
|
||||
user = UserFactory()
|
||||
CourseEnrollment.enroll(user=user, course_key=self.course.id)
|
||||
assert Notification.objects.all().count() == 0
|
||||
content = "<p><p> &nbsp;</p><br />"\
|
||||
"<p>abcd</p><br />"\
|
||||
"<p>&nbsp;</p><br /></p>"
|
||||
send_course_update_notification(self.course.id, content, self.user)
|
||||
assert Notification.objects.all().count() == 1
|
||||
notification = Notification.objects.first()
|
||||
assert notification.content == "<p><strong>abcd</strong></p>"
|
||||
|
||||
@@ -3,6 +3,7 @@ Common utility functions useful throughout the contentstore
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import configparser
|
||||
import html
|
||||
import logging
|
||||
import re
|
||||
from collections import defaultdict
|
||||
@@ -2258,6 +2259,7 @@ def clean_html_body(html_body):
|
||||
"""
|
||||
Get html body, remove tags and limit to 500 characters
|
||||
"""
|
||||
html_body = html.unescape(html_body).strip()
|
||||
html_body = BeautifulSoup(Truncator(html_body).chars(500, html=True), 'html.parser')
|
||||
text_content = html_body.get_text(separator=" ").strip()
|
||||
text_content = text_content.replace('\n', '').replace('\r', '')
|
||||
|
||||
Reference in New Issue
Block a user