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


Python RNewUserQueue.add_user方法代碼示例

本文整理匯總了Python中apps.profile.models.RNewUserQueue.add_user方法的典型用法代碼示例。如果您正苦於以下問題:Python RNewUserQueue.add_user方法的具體用法?Python RNewUserQueue.add_user怎麽用?Python RNewUserQueue.add_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apps.profile.models.RNewUserQueue的用法示例。


在下文中一共展示了RNewUserQueue.add_user方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: save

# 需要導入模塊: from apps.profile.models import RNewUserQueue [as 別名]
# 或者: from apps.profile.models.RNewUserQueue import add_user [as 別名]
    def save(self, profile_callback=None):
        username = self.cleaned_data['username']
        password = self.cleaned_data['password']

        email = self.cleaned_data.get('email', None)
        if email:
            email_exists = User.objects.filter(email__iexact=email).count()
            if email_exists:
                raise forms.ValidationError(_(u'Someone is already using that email address.'))

        exists = User.objects.filter(username__iexact=username).count()
        if exists:
            user_auth = authenticate(username=username, password=password)
            if not user_auth:
                raise forms.ValidationError(_(u'Someone is already using that username.'))
            else:
                return user_auth
        
        if not password:
            password = username
            
        new_user = User(username=username)
        new_user.set_password(password)
        new_user.is_active = False
        new_user.email = email
        new_user.save()
        new_user = authenticate(username=username,
                                password=password)
        
        MActivity.new_signup(user_id=new_user.pk)
        
        RNewUserQueue.add_user(new_user.pk)
        
        if new_user.email:
            EmailNewUser.delay(user_id=new_user.pk)
        
        if getattr(settings, 'AUTO_PREMIUM_NEW_USERS', False):
            new_user.profile.activate_premium()
        elif getattr(settings, 'AUTO_ENABLE_NEW_USERS', False):
            new_user.profile.activate_free()
        
        return new_user
開發者ID:1059232202,項目名稱:NewsBlur,代碼行數:44,代碼來源:forms.py

示例2: save

# 需要導入模塊: from apps.profile.models import RNewUserQueue [as 別名]
# 或者: from apps.profile.models.RNewUserQueue import add_user [as 別名]
    def save(self, profile_callback=None):
        username = self.cleaned_data["username"]
        password = self.cleaned_data["password"]

        email = self.cleaned_data.get("email", None)
        if email:
            email_exists = User.objects.filter(email__iexact=email).count()
            if email_exists:
                raise forms.ValidationError(_(u"此郵件地址已經被使用。"))

        exists = User.objects.filter(username__iexact=username).count()
        if exists:
            user_auth = authenticate(username=username, password=password)
            if not user_auth:
                raise forms.ValidationError(_(u"此用戶名已經被使用。"))
            else:
                return user_auth

        if not password:
            password = username

        new_user = User(username=username)
        new_user.set_password(password)
        new_user.is_active = False
        new_user.email = email
        new_user.save()
        new_user = authenticate(username=username, password=password)

        MActivity.new_signup(user_id=new_user.pk)

        RNewUserQueue.add_user(new_user.pk)

        if new_user.email:
            EmailNewUser.delay(user_id=new_user.pk)

        if getattr(settings, "AUTO_PREMIUM_NEW_USERS", False):
            new_user.profile.activate_premium()
        elif getattr(settings, "AUTO_ENABLE_NEW_USERS", False):
            new_user.profile.activate_free()

        return new_user
開發者ID:bruceyou,項目名稱:NewsBlur,代碼行數:43,代碼來源:forms.py


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