本文整理汇总了Python中pybossa.model.user.User.name方法的典型用法代码示例。如果您正苦于以下问题:Python User.name方法的具体用法?Python User.name怎么用?Python User.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybossa.model.user.User
的用法示例。
在下文中一共展示了User.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_errors
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import name [as 别名]
def test_user_errors(self):
"""Test USER model errors."""
user = User(
email_addr="[email protected]",
name="johndoe",
fullname="John Doe",
locale="en")
# User.name should not be nullable
user.name = None
db.session.add(user)
assert_raises(IntegrityError, db.session.commit)
db.session.rollback()
# User.fullname should not be nullable
user.name = "johndoe"
user.fullname = None
db.session.add(user)
assert_raises(IntegrityError, db.session.commit)
db.session.rollback()
# User.email_addr should not be nullable
user.name = "johndoe"
user.fullname = "John Doe"
user.email_addr = None
db.session.add(user)
assert_raises(IntegrityError, db.session.commit)
db.session.rollback()
示例2: manage_user
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import name [as 别名]
def manage_user(access_token, user_data):
"""Manage the user after signin"""
# We have to store the oauth_token in the session to get the USER fields
user = user_repo.get_by(google_user_id=user_data['id'])
# user never signed on
if user is None:
google_token = dict(oauth_token=access_token)
info = dict(google_token=google_token)
name = username_from_full_name(user_data['name'])
user = user_repo.get_by_name(name)
email = user_repo.get_by(email_addr=user_data['email'])
if ((user is None) and (email is None)):
user = User(fullname=user_data['name'],
name=name,
email_addr=user_data['email'],
google_user_id=user_data['id'],
info=info)
user_repo.save(user)
if newsletter.is_initialized():
newsletter.subscribe_user(user)
return user
else:
return None
else:
# Update the name to fit with new paradigm to avoid UTF8 problems
if type(user.name) == unicode or ' ' in user.name:
user.name = username_from_full_name(user.name)
user_repo.update(user)
return user
示例3: manage_user
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import name [as 别名]
def manage_user(access_token, user_data, next_url):
"""Manage the user after signin"""
# We have to store the oauth_token in the session to get the USER fields
user = user_repo.get_by(google_user_id=user_data['id'])
# user never signed on
if user is None:
google_token = dict(oauth_token=access_token)
info = dict(google_token=google_token)
name = user_data['name'].encode('ascii', 'ignore').lower().replace(" ", "")
user = user_repo.get_by_name(name)
email = user_repo.get_by(email_addr=user_data['email'])
if ((user is None) and (email is None)):
user = User(fullname=user_data['name'],
name=user_data['name'].encode('ascii', 'ignore')
.lower().replace(" ", ""),
email_addr=user_data['email'],
google_user_id=user_data['id'],
info=info)
user_repo.save(user)
return user
else:
return None
else:
# Update the name to fit with new paradigm to avoid UTF8 problems
if type(user.name) == unicode or ' ' in user.name:
user.name = user.name.encode('ascii', 'ignore').lower().replace(" ", "")
user_repo.update(user)
return user
示例4: test_domain_object_error
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import name [as 别名]
def test_domain_object_error(self):
"""Test DomainObject errors work."""
user = User()
user.name = "John"
d = user.dictize()
user.undictize(d)