def upload_avatar(name=None): """ """ extension = get_extension(name) up = UploadAvatar() path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension) if up.allowed_file() == False: success = False message = g.users_msg("error_upload_1") else: up.thumb(AVATAR_IMAGE_SIZE["large"], os.path.join(UP_AVATARS_TMP_FOLDER, path_image)) if path_image: success = True message = path_image if success: return dict(success=True, message=message) return dict(success=False, errors=[{"message": message}])
def upload_avatar(name=None): """ """ extension = get_extension(name) up = UploadAvatar() path_image = up.ajax_upload(UP_AVATARS_TMP_FOLDER, extension) if up.allowed_file() == False: success = False message = g.users_msg('error_upload_1') else: up.thumb(AVATAR_IMAGE_SIZE['large'], os.path.join(UP_AVATARS_TMP_FOLDER, path_image)) if path_image: success = True message = path_image if success: return dict(success=True, message=message) return dict(success=False, errors=[{"message": message}])
def allowed_file(self): """ """ self.extension = get_extension(self.filename) return '.' in self.filename and self.extension in ALLOWED_EXTENSIONS