Refactor apps to be in repo folder

This commit is contained in:
Isaac Bythewood
2018-02-08 21:57:49 -05:00
parent 9d00c74d18
commit 1fcdf2a9a3
33 changed files with 15 additions and 15 deletions

16
core/utils.py Normal file
View File

@@ -0,0 +1,16 @@
import hashlib
import os
def upload_path(instance, filename, **kwargs):
hasher = hashlib.md5()
for chunk in instance.image.chunks():
hasher.update(chunk)
hash = hasher.hexdigest()
base, ext = os.path.splitext(filename)
return '%(first)s/%(second)s/%(hash)s/%(base)s%(ext)s' % {
'first': hash[0],
'second': hash[1],
'hash': hash,
'base': base,
'ext': ext,
}