def create_user(user: User, is_admin: bool = False) -> User: """ 创建用户 :param user: User 用户ORM :param is_admin: bool 是否admin 创建头像信息,创建用户基本信息 """ user.roles = Role.get_by_user_default(is_admin) avator = Storages(**ADMIN_AVATOR) if is_admin else Storages(**USER_AVATOR) user.userinfo.avator = avator return user.save()
def create_user(user: User, is_admin: bool = False) -> User: """ 创建用户 :param user: User 用户ORM :param is_admin: bool 是否admin 创建头像信息,创建用户基本信息 """ user.roles = Role.get_by_user_default(is_admin) avator = ( Storages( # type: ignore store=load_avator_from_path(ADMIN_AVATOR["path"]), saved=True, **ADMIN_AVATOR) if is_admin else Storages( # type: ignore store=load_avator_from_path(USER_AVATOR["path"]), saved=True, **USER_AVATOR)) user.userinfo.update(avator=avator) return user