mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
RANDOMIZE_HASHES option
This commit is contained in:
parent
724a478738
commit
0aaa59e0a7
2 changed files with 6 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ class AvatarConf(AppConf):
|
|||
FACEBOOK_BACKUP = False
|
||||
FACEBOOK_GET_ID = None
|
||||
DISABLE_CACHE = False
|
||||
RANDOMIZE_HASHES = False
|
||||
|
||||
def configure_auto_generate_avatar_sizes(self, value):
|
||||
return value or getattr(settings, 'AVATAR_AUTO_GENERATE_SIZES',
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import binascii
|
||||
import datetime
|
||||
import os
|
||||
import hashlib
|
||||
|
|
@ -47,7 +48,10 @@ def avatar_file_path(instance=None, filename=None, size=None, ext=None):
|
|||
# File doesn't exist yet
|
||||
if settings.AVATAR_HASH_FILENAMES:
|
||||
(root, ext) = os.path.splitext(filename)
|
||||
filename = hashlib.md5(force_bytes(filename)).hexdigest()
|
||||
if settings.AVATAR_RANDOMIZE_HASHES:
|
||||
filename = binascii.hexlify(os.urandom(16)).decode('ascii')
|
||||
else:
|
||||
filename = hashlib.md5(force_bytes(filename)).hexdigest()
|
||||
filename = filename + ext
|
||||
if size:
|
||||
tmppath.extend(['resized', str(size)])
|
||||
|
|
|
|||
Loading…
Reference in a new issue