本文整理汇总了Python中flaskbb.user.models.Group.get_member_group方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_member_group方法的具体用法?Python Group.get_member_group怎么用?Python Group.get_member_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskbb.user.models.Group
的用法示例。
在下文中一共展示了Group.get_member_group方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from flaskbb.user.models import Group [as 别名]
# 或者: from flaskbb.user.models.Group import get_member_group [as 别名]
def create_user(username, password, email, groupname):
"""Creates a user.
Returns the created user.
:param username: The username of the user.
:param password: The password of the user.
:param email: The email address of the user.
:param groupname: The name of the group to which the user
should belong to.
"""
if groupname == "member":
group = Group.get_member_group()
else:
group = Group.query.filter(getattr(Group, groupname) == True).first()
user = User.create(username=username, password=password, email=email,
primary_group_id=group.id, activated=True)
return user
示例2: update_user
# 需要导入模块: from flaskbb.user.models import Group [as 别名]
# 或者: from flaskbb.user.models.Group import get_member_group [as 别名]
def update_user(username, password, email, groupname):
"""Update an existing user.
Returns the updated user.
:param username: The username of the user.
:param password: The password of the user.
:param email: The email address of the user.
:param groupname: The name of the group to which the user
should belong to.
"""
user = User.query.filter_by(username=username).first()
if user is None:
return None
if groupname == "member":
group = Group.get_member_group()
else:
group = Group.query.filter(getattr(Group, groupname) == True).first()
user.password = password
user.email = email
user.primary_group_id = group.id
return user.save()