當前位置: 首頁>>代碼示例>>Python>>正文


Python UserMgr.signup_user方法代碼示例

本文整理匯總了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.")
開發者ID:cambot,項目名稱:Bookie,代碼行數:14,代碼來源:test_signup.py

示例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.'
            }
        }
開發者ID:Cfhansen,項目名稱:Bookie,代碼行數:61,代碼來源:auth.py


注:本文中的bookie.models.auth.UserMgr.signup_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。