当前位置: 首页>>代码示例>>Python>>正文


Python Group.get_member_group方法代码示例

本文整理汇总了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
开发者ID:djsilcock,项目名称:flaskbb,代码行数:20,代码来源:populate.py

示例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()
开发者ID:djsilcock,项目名称:flaskbb,代码行数:25,代码来源:populate.py


注:本文中的flaskbb.user.models.Group.get_member_group方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。