From de2608009f971afa6ec96b298c3a4f38908e8906 Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Wed, 17 Aug 2016 17:40:17 -0400 Subject: [PATCH] Fix Unicode error on dashboard Programs with Unicode in their name would prevent the dashboard from loading. ECOM-5293. --- common/djangoapps/student/tests/tests.py | 10 +++++++++- lms/templates/dashboard/_dashboard_course_listing.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index b1d208433f..5e29bf1151 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -950,7 +950,7 @@ class RelatedProgramsTests(ProgramsApiConfigMixin, SharedModuleStoreTestCase): def expected_link_text(self, program): """Construct expected dashboard link text.""" - return '{name} {category}'.format(name=program['name'], category=program['category']) + return u'{name} {category}'.format(name=program['name'], category=program['category']) def test_related_programs_listed(self): """Verify that related programs are listed when the programs API returns data.""" @@ -982,6 +982,14 @@ class RelatedProgramsTests(ProgramsApiConfigMixin, SharedModuleStoreTestCase): self.assert_related_programs(response) self.assertNotContains(response, unrelated_program['name']) + def test_program_title_unicode(self): + """Verify that the dashboard can deal with programs whose titles contain Unicode.""" + self.programs[0]['name'] = u'Bases matemáticas para estudiar ingeniería' + self.mock_programs_api(self.programs) + + response = self.client.get(self.url) + self.assert_related_programs(response) + class UserAttributeTests(TestCase): """Tests for the UserAttribute model.""" diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index 0bf4d6d1c5..cf7d689770 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -284,7 +284,7 @@ from student.helpers import ( % for program in related_programs:
  • - ${'{name} {category}'.format(name=program['name'], category=program['category'])} + ${u'{name} {category}'.format(name=program['name'], category=program['category'])}
  • % endfor