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


Python MActivity.new_signup方法代码示例

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


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

示例1: save

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import new_signup [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
            
        new_user = User(username=username)
        new_user.set_password(password)
        new_user.is_active = True
        new_user.email = email
        new_user.save()
        new_user = authenticate(username=username,
                                password=password)
        
        MActivity.new_signup(user_id=new_user.pk)
        
        if new_user.email:
            EmailNewUser.delay(user_id=new_user.pk)
        
        return new_user
开发者ID:lgp171188,项目名称:NewsBlur,代码行数:34,代码来源:forms.py

示例2: save

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import new_signup [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

示例3: save

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import new_signup [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.social.models.MActivity.new_signup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。