本文整理匯總了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.'
}
}