mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-05-19 04:51:08 +00:00
Replace hashlib by django's md5_constructor
This commit is contained in:
parent
984131894b
commit
c364ca7aa1
1 changed files with 3 additions and 3 deletions
|
|
@ -5,7 +5,7 @@ from django.db import models
|
|||
from django.contrib.auth.models import User
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils.translation import ugettext as _
|
||||
import hashlib
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
|
|
@ -24,7 +24,7 @@ from avatar import AVATAR_STORAGE_DIR, AVATAR_RESIZE_METHOD, \
|
|||
def avatar_file_path(instance=None, filename=None, size=None, ext=None):
|
||||
tmppath = [AVATAR_STORAGE_DIR]
|
||||
if AVATAR_HASH_USERDIRNAMES:
|
||||
tmp = hashlib.md5(instance.user.username).hexdigest()
|
||||
tmp = md5_constructor(instance.user.username).hexdigest()
|
||||
tmppath.extend([tmp[0], tmp[1], instance.user.username])
|
||||
else:
|
||||
tmppath.append(instance.user.username)
|
||||
|
|
@ -42,7 +42,7 @@ def avatar_file_path(instance=None, filename=None, size=None, ext=None):
|
|||
# File doesn't exist yet
|
||||
if AVATAR_HASH_FILENAMES:
|
||||
(root, ext) = os.path.splitext(filename)
|
||||
filename = hashlib.md5(filename).hexdigest()
|
||||
filename = md5_constructor(filename).hexdigest()
|
||||
filename = filename + ext
|
||||
if size:
|
||||
tmppath.extend(['resized', str(size)])
|
||||
|
|
|
|||
Loading…
Reference in a new issue