Commit 4040a489 by benjaoming

Merge pull request #254 from Mobeye/python3

Fix image upload when IMAGE_PATH_OBSCURIFY setting is enabled
parents ea3ef803 d43557a7
...@@ -3,6 +3,6 @@ South ...@@ -3,6 +3,6 @@ South
Markdown>2.2.0 Markdown>2.2.0
django-sekizai>=0.7 django-sekizai>=0.7
django-mptt>=0.5.3 django-mptt>=0.5.3
sorl-thumbnail sorl-thumbnail==11.12.1b
Pillow Pillow
six six
...@@ -20,9 +20,8 @@ def upload_path(instance, filename): ...@@ -20,9 +20,8 @@ def upload_path(instance, filename):
upload_path = settings.IMAGE_PATH upload_path = settings.IMAGE_PATH
upload_path = upload_path.replace('%aid', str(instance.plugin.image.article.id)) upload_path = upload_path.replace('%aid', str(instance.plugin.image.article.id))
if settings.IMAGE_PATH_OBSCURIFY: if settings.IMAGE_PATH_OBSCURIFY:
import random, hashlib import uuid
m=hashlib.md5(str(random.randint(0,100000000000000))) upload_path = os.path.join(upload_path, uuid.uuid4().hex)
upload_path = os.path.join(upload_path, m.hexdigest())
return os.path.join(upload_path, filename) return os.path.join(upload_path, filename)
class Image(RevisionPlugin): class Image(RevisionPlugin):
......
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