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


Python User.activated方法代码示例

本文整理汇总了Python中flaskbb.user.models.User.activated方法的典型用法代码示例。如果您正苦于以下问题:Python User.activated方法的具体用法?Python User.activated怎么用?Python User.activated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskbb.user.models.User的用法示例。


在下文中一共展示了User.activated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_admin_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import activated [as 别名]
def create_admin_user(username, password, email):
    """Creates the administrator user.
    Returns the created admin user.

    :param username: The username of the user.
    :param password: The password of the user.
    :param email: The email address of the user.
    """
    admin_group = Group.query.filter_by(admin=True).first()
    user = User()

    user.username = username
    user.password = password
    user.email = email
    user.primary_group_id = admin_group.id
    user.activated = True

    user.save()
    return user
开发者ID:AnantharamanG2,项目名称:flaskbb,代码行数:21,代码来源:populate.py

示例2: create_test_data

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import activated [as 别名]
def create_test_data(users=5, categories=2, forums=2, topics=1, posts=1):
    """Creates 5 users, 2 categories and 2 forums in each category.
    It also creates a new topic topic in each forum with a post.
    Returns the amount of created users, categories, forums, topics and posts
    as a dict.

    :param users: The number of users.
    :param categories: The number of categories.
    :param forums: The number of forums which are created in each category.
    :param topics: The number of topics which are created in each forum.
    :param posts: The number of posts which are created in each topic.
    """
    create_default_groups()
    create_default_settings()

    data_created = {'users': 0, 'categories': 0, 'forums': 0,
                    'topics': 0, 'posts': 0}

    # create 5 users
    for u in range(1, users + 1):
        username = "test%s" % u
        email = "test%[email protected]" % u
        user = User(username=username, password="test", email=email)
        user.primary_group_id = u
        user.activated = True
        user.save()
        data_created['users'] += 1

    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()

    # lets send them a few private messages
    for i in range(1, 3):
        # TODO
        pass

    # create 2 categories
    for i in range(1, categories + 1):
        category_title = "Test Category %s" % i
        category = Category(title=category_title,
                            description="Test Description")
        category.save()
        data_created['categories'] += 1

        # create 2 forums in each category
        for j in range(1, forums + 1):
            if i == 2:
                j += 2

            forum_title = "Test Forum %s %s" % (j, i)
            forum = Forum(title=forum_title, description="Test Description",
                          category_id=i)
            forum.save()
            data_created['forums'] += 1

            for t in range(1, topics + 1):
                # create a topic
                topic = Topic(title="Test Title %s" % j)
                post = Post(content="Test Content")

                topic.save(post=post, user=user1, forum=forum)
                data_created['topics'] += 1

                for p in range(1, posts + 1):
                    # create a second post in the forum
                    post = Post(content="Test Post")
                    post.save(user=user2, topic=topic)
                    data_created['posts'] += 1

    return data_created
开发者ID:djsilcock,项目名称:flaskbb,代码行数:72,代码来源:populate.py


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