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


Python User.save方法代码示例

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


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

示例1: admin_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def admin_user(default_groups):
    """Creates a admin user."""
    user = User(username="test_admin", email="[email protected]",
                password="test", primary_group=default_groups[0],
                activated=True)
    user.save()
    return user
开发者ID:BenDerPan,项目名称:flaskbb,代码行数:9,代码来源:user.py

示例2: super_moderator_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def super_moderator_user(default_groups):
    """Creates a super moderator user."""
    user = User(username="test_super_mod", email="[email protected]",
                password="test", primary_group=default_groups[1],
                activated=True)
    user.save()
    return user
开发者ID:BenDerPan,项目名称:flaskbb,代码行数:9,代码来源:user.py

示例3: user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def user(default_groups):
    """Creates a user with normal permissions."""
    user = User(username="test_normal", email="[email protected]",
                password="test", primary_group=default_groups[3],
                activated=True)
    user.save()
    return user
开发者ID:BenDerPan,项目名称:flaskbb,代码行数:9,代码来源:user.py

示例4: create_admin_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def create_admin_user(username, password, email):
    """
    Creates the administrator user
    """
    admin_group = Group.query.filter_by(admin=True).first()
    user = User(username=username, password=password, email=email,
                date_joined=datetime.utcnow(), primary_group_id=admin_group.id)
    user.save()
开发者ID:hvdklauw,项目名称:flaskbb,代码行数:10,代码来源:populate.py

示例5: unactivated_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def unactivated_user(default_groups):
    """
    Creates an unactivated user in the default user group
    """
    user = User(username='notactive', email='[email protected]',
                password='password', primary_group=default_groups[3],
                activated=False)
    user.save()
    return user
开发者ID:eirnym,项目名称:flaskbb,代码行数:11,代码来源:user.py

示例6: moderator_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def moderator_user(forum, default_groups):
    """Creates a test user for whom the permissions should be checked"""

    user = User(username="test_mod", email="[email protected]",
                password="test", primary_group_id=default_groups[2].id)
    user.save()

    forum.moderators.append(user)
    forum.save()
    return user
开发者ID:hugleecool,项目名称:flaskbb,代码行数:12,代码来源:user.py

示例7: moderator_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def moderator_user(user, forum, default_groups):
    """Creates a test user with moderator permissions."""

    user = User(username="test_mod", email="[email protected]",
                password="test", primary_group=default_groups[2])
    user.save()

    forum.moderators.append(user)
    forum.save()
    return user
开发者ID:0xsKu,项目名称:flaskbb,代码行数:12,代码来源:user.py

示例8: Fred

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def Fred(default_groups):
    """Fred is an interloper and bad intentioned user, he attempts to
    access areas he shouldn't, he posts trollish and spammy content,
    he does everything he can to destroy the board.

    Our job is stop Fred.
    """
    fred = User(username='Fred', email='[email protected]',
                password='fred', primary_group=default_groups[3])
    fred.save()
    return fred
开发者ID:0xsKu,项目名称:flaskbb,代码行数:13,代码来源:user.py

示例9: create_admin_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def create_admin_user(username, password, email):
    """
    Creates the administrator 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.save()
开发者ID:aregsar,项目名称:flaskbb,代码行数:15,代码来源:populate.py

示例10: create_test_data

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def create_test_data():
    """
    Creates 5 users, 2 categories and 2 forums in each category. It also opens
    a new topic topic in each forum with a post.
    """
    create_default_groups()
    create_default_settings()

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

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

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

        # create 2 forums in each category
        for j in range(1, 3):
            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()

            # create a topic
            topic = Topic()
            post = Post()

            topic.title = "Test Title %s" % j
            post.content = "Test Content"
            topic.save(post=post, user=user1, forum=forum)

            # create a second post in the forum
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
开发者ID:aregsar,项目名称:flaskbb,代码行数:50,代码来源:populate.py

示例11: save

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
 def save(self):
     user = User(username=self.username.data,
                 email=self.email.data,
                 password=self.password.data,
                 date_joined=datetime.utcnow(),
                 primary_group_id=4)
     return user.save()
开发者ID:FooBarQuaxx,项目名称:flaskbb,代码行数:9,代码来源:forms.py

示例12: create_admin_user

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [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

示例13: create_test_data

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
def create_test_data():

    create_default_groups()

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

    # create a category
    category = Forum(is_category=True, title="Test Category",
                     description="Test Description")
    category.save()

    # create 2 forums in the category
    for i in range(1, 3):
        forum_title = "Test Forum %s " % i
        forum = Forum(title=forum_title, description="Test Description",
                      parent_id=category.id)
        forum.save()

        # Create a subforum
        subforum_title = "Test Subforum %s " % i
        subforum = Forum(title=subforum_title,
                         description="Test Description", parent_id=forum.id)
        subforum.save()

    user = User.query.filter_by(id=1).first()

    # create 1 topic in each forum
    for i in range(2, 6):  # Forum ids are not sequential because categories.
        forum = Forum.query.filter_by(id=i).first()

        topic = Topic()
        post = Post()

        topic.title = "Test Title %s" % (i-1)
        post.content = "Test Content"
        topic.save(user=user, forum=forum, post=post)
开发者ID:ulysseswolf,项目名称:flaskbb,代码行数:44,代码来源:populate.py

示例14: save

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
 def save(self):
     user = User(**self.data)
     return user.save()
开发者ID:RJacksonm1,项目名称:flaskbb,代码行数:5,代码来源:forms.py

示例15: save

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import save [as 别名]
 def save(self):
     data = self.data
     data.pop('submit', None)
     user = User(**data)
     return user.save()
开发者ID:abshkd,项目名称:flaskbb,代码行数:7,代码来源:forms.py


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