本文整理汇总了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
示例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
示例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
示例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()
示例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
示例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
示例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
示例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
示例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()
示例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)
示例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()
示例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
示例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)
示例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()
示例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()