Skip to content
Snippets Groups Projects
Commit 6f326f72 authored by Diana Huang's avatar Diana Huang Committed by GitHub
Browse files

Merge pull request #15136 from edx/diana/replace-welcome-message-urls

Replace urls in the welcome message.
parents aa4eba33 9ecbc9bf
No related merge requests found
......@@ -67,6 +67,16 @@ class TestWelcomeMessageView(SharedModuleStoreTestCase):
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'Second Update')
def test_replace_urls(self):
img_url = 'img.png'
create_course_update(self.course, self.user, "<img src='/static/{url}'>".format(url=img_url))
response = self.client.get(welcome_message_url(self.course))
self.assertContains(response, "/asset-v1:{org}+{course}+{run}+type@asset+block/img.png".format(
org=self.course.id.org,
course=self.course.id.course,
run=self.course.id.run
))
def test_empty_welcome_message(self):
response = self.client.get(welcome_message_url(self.course))
self.assertEqual(response.status_code, 204)
......@@ -45,4 +45,8 @@ class WelcomeMessageFragmentView(EdxFragmentView):
# Return the course update with the most recent publish date
info_block = getattr(info_module, '_xmodule', info_module)
ordered_updates = info_block.ordered_updates()
return ordered_updates[0]['content'] if ordered_updates else None
content = None
if ordered_updates:
content = info_block.system.replace_urls(ordered_updates[0]['content'])
return content
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment