本文整理汇总了Python中bookie.models.auth.UserMgr.signup_user方法的典型用法代码示例。如果您正苦于以下问题:Python UserMgr.signup_user方法的具体用法?Python UserMgr.signup_user怎么用?Python UserMgr.signup_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bookie.models.auth.UserMgr
的用法示例。
在下文中一共展示了UserMgr.signup_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSignupWorks
# 需要导入模块: from bookie.models.auth import UserMgr [as 别名]
# 或者: from bookie.models.auth.UserMgr import signup_user [as 别名]
def testSignupWorks(self):
"""Signing up stores an activation."""
email = '[email protected]'
UserMgr.signup_user(email, 'testcase')
activations = Activation.query.all()
self.assertTrue(len(activations) == 1)
act = activations[0]
self.assertEqual(email, act.user.email,
"The activation email is the correct one.")
示例2: signup_process
# 需要导入模块: from bookie.models.auth import UserMgr [as 别名]
# 或者: from bookie.models.auth.UserMgr import signup_user [as 别名]
def signup_process(request):
"""Process the signup request
If there are any errors drop to the same template with the error
information.
"""
params = request.params
email = params.get('email', None)
if not email:
# if still no email, I give up!
return {
'errors': {
'email': 'Please supply an email address to sign up.'
}
}
# first see if the user is already in the system
exists = UserMgr.get(email=email)
if exists:
return {
'errors': {
'email': 'The user has already signed up.'
}
}
new_user = UserMgr.signup_user(email, 'signup')
if new_user:
# then this user is able to invite someone
# log it
AuthLog.reactivate(new_user.username)
# and then send an email notification
# @todo the email side of things
settings = request.registry.settings
# Add a queue job to send the user a notification email.
tasks.email_signup_user.delay(
new_user.email,
"Enable your Bookie account",
settings,
request.route_url(
'reset',
username=new_user.username,
reset_key=new_user.activation.code
)
)
# And let the user know they're signed up.
return {
'message': 'Thank you for signing up from: ' + new_user.email
}
else:
return {
'errors': {
'email': 'There was an unknown error signing up.'
}
}