本文整理汇总了Python中ziggurat_foundations.models.services.user.UserService.users_for_perms方法的典型用法代码示例。如果您正苦于以下问题:Python UserService.users_for_perms方法的具体用法?Python UserService.users_for_perms怎么用?Python UserService.users_for_perms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ziggurat_foundations.models.services.user.UserService
的用法示例。
在下文中一共展示了UserService.users_for_perms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_users_for_perms
# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import users_for_perms [as 别名]
def test_users_for_perms(self, db_session):
user = User(user_name="aaa", email="aaa", status=0)
UserService.set_password(user, "password")
aaa_perm = UserPermission(perm_name="aaa")
bbb_perm = UserPermission(perm_name="bbb")
bbb2_perm = UserPermission(perm_name="bbb")
user.user_permissions.append(aaa_perm)
user.user_permissions.append(bbb_perm)
user2 = User(user_name="bbb", email="bbb", status=0)
UserService.set_password(user2, "password")
user2.user_permissions.append(bbb2_perm)
user3 = User(user_name="ccc", email="ccc", status=0)
UserService.set_password(user3, "password")
group = add_group(db_session)
group.users.append(user3)
db_session.add(user)
db_session.add(user2)
db_session.flush()
users = UserService.users_for_perms(["aaa"], db_session=db_session)
assert len(users.all()) == 1
assert users[0].user_name == "aaa"
users = UserService.users_for_perms(["bbb"], db_session=db_session).all()
assert len(users) == 2
assert ["aaa", "bbb"] == sorted([u.user_name for u in users])
users = UserService.users_for_perms(
["aaa", "bbb", "manage_apps"], db_session=db_session
)
assert ["aaa", "bbb", "ccc"] == sorted([u.user_name for u in users])
示例2: users_for_perms
# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import users_for_perms [as 别名]
def users_for_perms(cls, perm_names, db_session=None):
"""
.. deprecated:: 0.8
:param perm_names:
:param db_session:
:return:
"""
db_session = get_db_session(db_session)
return UserService.users_for_perms(perm_names=perm_names,
db_session=db_session)