Skip to content

Commit

Permalink
Updated clean upload file names
Browse files Browse the repository at this point in the history
  • Loading branch information
remik committed Jun 1, 2016
1 parent 6977568 commit bb6f5ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pages/placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,16 @@ def get_filename(page, placeholder, data):
Generate a stable filename using the orinal filename.
"""
name_parts = data.name.split('.')
name = slugify('.'.join(name_parts[:-1]), allow_unicode=True)
if len(name_parts) > 1:
name = slugify('.'.join(name_parts[:-1]), allow_unicode=True)
ext = slugify(name_parts[-1])
name = name + '.' + ext
else:
name = slugify(data.name)
filename = os.path.join(
settings.PAGE_UPLOAD_ROOT,
'page_' + str(page.id),
placeholder.ctype + '-' + str(time.time()) + '-' + name + '.' + name_parts[-1]
placeholder.ctype + '-' + str(time.time()) + '-' + name
)
return filename

Expand Down

0 comments on commit bb6f5ae

Please sign in to comment.