def get_upload_filename(upload_name, user): # If CKEDITOR_RESTRICT_BY_USER is True upload file to user specific path. if getattr(settings, 'CKEDITOR_RESTRICT_BY_USER', False): user_path = user.username else: user_path = '' # Complete upload path (upload_path + date_path). upload_path = os.path.join( settings.CKEDITOR_UPLOAD_PATH, user_path) if getattr(settings, "CKEDITOR_UPLOAD_SLUGIFY_FILENAME", True): upload_name = utils.slugify_filename(upload_name) return default_storage.get_available_name(os.path.join(upload_path, upload_name))
def get_upload_filename(upload_name, user): # If CKEDITOR_RESTRICT_BY_USER is True upload file to user specific path. if getattr(settings, "CKEDITOR_RESTRICT_BY_USER", False): user_path = user.username else: user_path = "" # Generate date based path to put uploaded file. date_path = datetime.now().strftime("%Y/%m/%d") # Complete upload path (upload_path + date_path). upload_path = os.path.join(settings.CKEDITOR_UPLOAD_PATH, user_path, date_path) if getattr(settings, "CKEDITOR_UPLOAD_SLUGIFY_FILENAME", True): upload_name = utils.slugify_filename(upload_name) return default_storage.get_available_name(os.path.join(upload_path, upload_name))
def get_upload_filename(upload_name, user): # If CKEDITOR_RESTRICT_BY_USER is True upload file to user specific path. if getattr(settings, 'CKEDITOR_RESTRICT_BY_USER', False): user_path = user.username else: user_path = '' # Generate date based path to put uploaded file. date_path = datetime.now().strftime('%Y/%m/%d') # Complete upload path (upload_path + date_path). upload_path = os.path.join( settings.CKEDITOR_UPLOAD_PATH, user_path, date_path) if getattr(settings, "CKEDITOR_UPLOAD_SLUGIFY_FILENAME", True): upload_name = utils.slugify_filename(upload_name) return default_storage.get_available_name(os.path.join(upload_path, upload_name))