Merge pull request #13836 from eduNEXT/fmo/unicode_username_fixes
Quick fixes for users with unicode usernames.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user