def media_filename(instance, filename): avoid_collision = uuid.uuid4().hex[:8] name_parts = filename.split('.') 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(filename) filename = os.path.join(settings.PAGE_UPLOAD_ROOT, 'medias', name) return filename
def get_filename(page, placeholder, data): """ Generate a stable filename using the orinal filename. """ name_parts = data.name.split('.') 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) return filename
def media_filename(instance, filename): avoid_collision = uuid.uuid4().hex[:8] name_parts = filename.split('.') 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(filename) filename = os.path.join( settings.PAGE_UPLOAD_ROOT, 'medias', name ) return filename
def get_filename(page, placeholder, data): """ Generate a stable filename using the orinal filename. """ name_parts = data.name.split('.') 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 ) return filename
def get_filename(page, content_type, data): """ Generate a stable filename using the original filename of the type. """ avoid_collision = uuid.uuid4().hex[:8] name_parts = data.name.split('.') 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), content_type + '-' + avoid_collision + '-' + name) return filename
def get_filename(page, content_type, data): """ Generate a stable filename using the original filename of the type. """ avoid_collision = uuid.uuid4().hex[:8] name_parts = data.name.split('.') 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), content_type + '-' + avoid_collision + '-' + name ) return filename