当前位置: 首页>>代码示例>>Python>>正文


Python DekiUserBackend.post_mindtouch_user方法代码示例

本文整理汇总了Python中dekicompat.backends.DekiUserBackend.post_mindtouch_user方法的典型用法代码示例。如果您正苦于以下问题:Python DekiUserBackend.post_mindtouch_user方法的具体用法?Python DekiUserBackend.post_mindtouch_user怎么用?Python DekiUserBackend.post_mindtouch_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dekicompat.backends.DekiUserBackend的用法示例。


在下文中一共展示了DekiUserBackend.post_mindtouch_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_inactive_user

# 需要导入模块: from dekicompat.backends import DekiUserBackend [as 别名]
# 或者: from dekicompat.backends.DekiUserBackend import post_mindtouch_user [as 别名]
 def create_inactive_user(self, username, password, email):
     """
     Create a new, inactive ``User`` and ``Profile``, generates a
     ``RegistrationProfile`` and email its activation key to the
     ``User``, returning the new ``User``.
     """
     new_user = User.objects.create_user(username, email, password)
     new_user.is_active = False
     new_user.save()
     profile = UserProfile.objects.create(user=new_user)
     try:
         deki_user = DekiUserBackend.post_mindtouch_user(new_user)
     except MindTouchAPIError, e:
         new_user.delete()
         raise e
开发者ID:GPHemsley,项目名称:kuma,代码行数:17,代码来源:models.py

示例2: create_inactive_user

# 需要导入模块: from dekicompat.backends import DekiUserBackend [as 别名]
# 或者: from dekicompat.backends.DekiUserBackend import post_mindtouch_user [as 别名]
    def create_inactive_user(self, username, password, email):
        """
        Create a new, inactive ``User`` and ``Profile``, generates a
        ``RegistrationProfile`` and email its activation key to the
        ``User``, returning the new ``User``.
        """
        new_user = User.objects.create_user(username, email, password)
        new_user.is_active = False
        new_user.save()
        profile = UserProfile.objects.create(user=new_user)
        deki_user = DekiUserBackend.post_mindtouch_user(new_user)
        profile.deki_user_id = deki_user.id
        profile.save()

        registration_profile = self.create_profile(new_user)

        self.send_confirmation_email(registration_profile)

        return new_user
开发者ID:pmclanahan,项目名称:kuma,代码行数:21,代码来源:models.py

示例3: browserid_register

# 需要导入模块: from dekicompat.backends import DekiUserBackend [as 别名]
# 或者: from dekicompat.backends.DekiUserBackend import post_mindtouch_user [as 别名]
def browserid_register(request):
    """Handle user creation when assertion is valid, but no existing user"""
    statsd_waffle_incr('users.browserid_register', 'signin_metrics')
    redirect_to = request.session.get(SESSION_REDIRECT_TO,
        getattr(settings, 'LOGIN_REDIRECT_URL', reverse('home')))
    email = request.session.get(SESSION_VERIFIED_EMAIL, None)

    if not email:
        # This is pointless without a verified email.
        return HttpResponseRedirect(redirect_to)

    # Set up the initial forms
    register_form = BrowserIDRegisterForm()
    login_form = AuthenticationForm()

    if request.method == 'POST':
        statsd_waffle_incr('users.browserid_register.POST', 'signin_metrics')

        # If the profile creation form was submitted...
        if 'register' == request.POST.get('action', None):
            register_form = BrowserIDRegisterForm(request.POST)
            if register_form.is_valid():
                try:
                    # If the registration form is valid, then create a new
                    # Django user, a new MindTouch user, and link the two
                    # together.
                    # TODO: This all belongs in model classes
                    username = register_form.cleaned_data['username']

                    user = User.objects.create(username=username, email=email)
                    user.set_unusable_password()
                    user.save()

                    profile = UserProfile.objects.create(user=user)
                    if settings.DEKIWIKI_ENDPOINT:
                        deki_user = DekiUserBackend.post_mindtouch_user(user)
                        profile.deki_user_id = deki_user.id
                    profile.save()

                    user.backend = 'django_browserid.auth.BrowserIDBackend'
                    auth.login(request, user)

                    # Bounce to the newly created profile page, since the user
                    # might want to review & edit.
                    statsd_waffle_incr('users.browserid_register.POST.SUCCESS',
                                       'signin_metrics')
                    redirect_to = request.session.get(SESSION_REDIRECT_TO,
                                                    profile.get_absolute_url())
                    return set_browserid_explained(
                        _redirect_with_mindtouch_login(redirect_to,
                                                       user.username))
                except MindTouchAPIError:
                    if user:
                        user.delete()
                    return render(request, '500.html',
                                        {'error_message': "We couldn't "
                                        "register a new account at this time. "
                                        "Please try again later."})

    # HACK: Pretend the session was modified. Otherwise, the data disappears
    # for the next request.
    request.session.modified = True

    return render(request, 'users/browserid_register.html',
                        {'login_form': login_form,
                         'register_form': register_form})
开发者ID:Web5design,项目名称:kuma,代码行数:68,代码来源:views.py

示例4: browserid_register

# 需要导入模块: from dekicompat.backends import DekiUserBackend [as 别名]
# 或者: from dekicompat.backends.DekiUserBackend import post_mindtouch_user [as 别名]
def browserid_register(request):
    """Handle user creation when assertion is valid, but no existing user"""
    redirect_to = request.session.get(SESSION_REDIRECT_TO,
        getattr(settings, 'LOGIN_REDIRECT_URL', reverse('home')))
    email = request.session.get(SESSION_VERIFIED_EMAIL, None)

    if not email:
        # This is pointless without a verified email.
        return HttpResponseRedirect(redirect_to)

    # Set up the initial forms
    register_form = BrowserIDRegisterForm()
    login_form = AuthenticationForm()

    if request.method == 'POST':

        # If the profile creation form was submitted...
        if 'register' == request.POST.get('action', None):
            register_form = BrowserIDRegisterForm(request.POST)
            if register_form.is_valid():
                # If the registration form is valid, then create a new Django
                # user, a new MindTouch user, and link the two together.
                # TODO: This all belongs in model classes
                username = register_form.cleaned_data['username']

                user = User.objects.create(username=username, email=email)
                user.set_unusable_password()
                user.save()

                profile = UserProfile.objects.create(user=user)
                deki_user = DekiUserBackend.post_mindtouch_user(user)
                profile.deki_user_id = deki_user.id
                profile.save()

                user.backend = 'django_browserid.auth.BrowserIDBackend'
                auth.login(request, user)

                # Bounce to the newly created profile page, since the user
                # might want to review & edit.
                return HttpResponseRedirect(profile.get_absolute_url())

        else:
            # If login was valid, then set to the verified email
            login_form = handle_login(request)
            if login_form.is_valid():
                if request.user.is_authenticated():
                    # Change email to new verified email, for next time
                    user = request.user
                    user.email = email
                    user.save()
                    return _redirect_with_mindtouch_login(redirect_to,
                        login_form.cleaned_data.get('username'),
                        login_form.cleaned_data.get('password'))

    # HACK: Pretend the session was modified. Otherwise, the data disappears
    # for the next request.
    request.session.modified = True

    return jingo.render(request, 'users/browserid_register.html',
                        {'login_form': login_form,
                         'register_form': register_form})
开发者ID:pmclanahan,项目名称:kuma,代码行数:63,代码来源:views.py


注:本文中的dekicompat.backends.DekiUserBackend.post_mindtouch_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。