Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To support UNICODE xblock.location #6167

Merged
merged 1 commit into from
Mar 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def xblock_studio_url(xblock, parent_xblock=None):
elif category in ('chapter', 'sequential'):
return u'{url}?show={usage_key}'.format(
url=reverse_course_url('course_handler', xblock.location.course_key),
usage_key=urllib.quote(unicode(xblock.location))
usage_key=urllib.quote(unicode(xblock.location).encode('utf8'))
)
elif category == 'library':
library_key = xblock.location.course_key
Expand Down
13 changes: 13 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from contentstore.tests.utils import CourseTestCase
from contentstore.views.helpers import xblock_studio_url, xblock_type_display_name
from xmodule.modulestore.tests.factories import ItemFactory, LibraryFactory
from xmodule.modulestore.xml import XMLModuleStore
from xmodule.tests import DATA_DIR
from django.utils import http


Expand Down Expand Up @@ -55,6 +57,17 @@ def test_xblock_studio_url(self):
expected_url = u'/library/{}'.format(unicode(library.location.library_key))
self.assertEqual(xblock_studio_url(library), expected_url)

def test_unicode_xblock_studio_url(self):

#import unicode course
modulestore = XMLModuleStore(DATA_DIR, course_dirs=['2014_Uni'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes this a Unicode course?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

courses = modulestore.get_courses()
course = courses[0]

# Verify course URL
course_url = http.urlquote('/course/{}'.format(course.id))
self.assertEqual(xblock_studio_url(course), course_url)

def test_xblock_type_display_name(self):

# Verify chapter type display name
Expand Down