Commit 38e787b6 by Felipe Montoya

Quick fixes for users with unicode usernames.

This changes fix the bookmarks feature and image upload
parent ba491a64
......@@ -70,7 +70,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
'unit_title': self.display_name_with_default if not is_child_of_vertical else None,
'show_bookmark_button': not is_child_of_vertical,
'bookmarked': child_context['bookmarked'],
'bookmark_id': "{},{}".format(child_context['username'], unicode(self.location))
'bookmark_id': u"{},{}".format(child_context['username'], unicode(self.location))
}))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/vertical_student_view.js'))
......
......@@ -98,7 +98,7 @@ class Bookmark(TimeStampedModel):
"""
Return the resource id: {username,usage_id}.
"""
return "{0},{1}".format(self.user.username, self.usage_key) # pylint: disable=no-member
return u"{0},{1}".format(self.user.username, self.usage_key) # pylint: disable=no-member
@property
def display_name(self):
......
......@@ -51,7 +51,7 @@ class BookmarkSerializer(serializers.ModelSerializer):
"""
Return the REST resource id: {username,usage_id}.
"""
return "{0},{1}".format(bookmark.user.username, bookmark.usage_key)
return u"{0},{1}".format(bookmark.user.username, bookmark.usage_key)
def get_path(self, bookmark):
"""
......
......@@ -38,7 +38,8 @@ def _make_profile_image_name(username):
Returns the user-specific part of the image filename, based on a hash of
the username.
"""
return hashlib.md5(settings.PROFILE_IMAGE_SECRET_KEY + username).hexdigest()
hash_input = settings.PROFILE_IMAGE_SECRET_KEY + username
return hashlib.md5(hash_input.encode('utf-8')).hexdigest()
def _get_profile_image_filename(name, size, file_extension=PROFILE_IMAGE_FILE_EXTENSION):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment