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


Python UserSocialAuth.create_social_auth方法代码示例

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


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

示例1: _post_save

# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_social_auth [as 别名]
    def _post_save(sender, instance, **kwargs):
        if not hasattr(instance, "auth_identity"):
            # not triggered by user.
            return

        original_instance = getattr(instance, "_original_instance") if hasattr(instance, "_original_instance") else None
        auth_identity = getattr(instance, "auth_identity")
        if auth_identity:
            # add email to email identity and social auth if not exist
            EmailIdentity.objects.get_or_create(email=instance.email, user=instance.user)
            if not UserSocialAuth.objects.filter(user=instance.user, provider="email", uid=instance.email).exists():
                user_social_auth = UserSocialAuth.create_social_auth(instance.user, instance.email, 'email')
                user_social_auth.extra_data = {'email': [instance.email]}
                user_social_auth.save()

        if original_instance and (original_instance.email != instance.email or not auth_identity):
            # delete the profile's email from email identity and social auth
            EmailIdentity.objects.filter(email=original_instance.email, user=original_instance.user).delete()
            UserSocialAuth.objects.filter(provider="email", uid=original_instance.email, user=original_instance.user).delete()
开发者ID:rockychen-dpaw,项目名称:ledger,代码行数:21,代码来源:models.py

示例2: setUp

# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_social_auth [as 别名]
    def setUp(self):
        user = EmailUser.objects.create(email=REGISTERED_USER_EMAIL)
        UserSocialAuth.create_social_auth(user, user.email, 'email')

        self.client = Client()
开发者ID:ropable,项目名称:ledger,代码行数:7,代码来源:tests.py

示例3: create_user

# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_social_auth [as 别名]
def create_user(**kwargs):
    user = EmailUser.objects.create(**kwargs)
    UserSocialAuth.create_social_auth(user, user.email, "email")
    return user
开发者ID:ropable,项目名称:ledger,代码行数:6,代码来源:helpers.py

示例4: _post_save

# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_social_auth [as 别名]
    def _post_save(sender, instance, **kwargs):
        if not hasattr(instance, "auth_identity"):
            # not triggered by user.
            return

        original_instance = getattr(instance, "_original_instance") if hasattr(instance, "_original_instance") else None
        auth_identity = getattr(instance, "auth_identity")
        if auth_identity:
            # add email to email identity and social auth if not exist
            EmailIdentity.objects.get_or_create(email=instance.email, user=instance.user)
            if not UserSocialAuth.objects.filter(user=instance.user, provider="email", uid=instance.email).exists():
                user_social_auth = UserSocialAuth.create_social_auth(instance.user, instance.email, 'email')
                user_social_auth.extra_data = {'email': [instance.email]}
                user_social_auth.save()

        if original_instance and (original_instance.email != instance.email or not auth_identity):
            # delete the profile's email from email identity and social auth
            EmailIdentity.objects.filter(email=original_instance.email, user=original_instance.user).delete()
            UserSocialAuth.objects.filter(provider="email", uid=original_instance.email, user=original_instance.user).delete()

        if not original_instance:
            address = instance.postal_address
            try:
                # Check if the user has the same profile address
                # Check if there is a user address
                oscar_add = UserAddress.objects.get(
                    line1 = address.line1,
                    line2 = address.line2,
                    line3 = address.line3,
                    line4 = address.locality,
                    state = address.state,
                    postcode = address.postcode,
                    country = Country.objects.get(iso_3166_1_a2=address.country),
                    user = instance.user
                )
                if not address.oscar_address:
                    address.oscar_address = oscar_add
                    address.save()
                elif address.oscar_address.id != oscar_add.id:
                    address.oscar_address = oscar_add
                    address.save()
            except UserAddress.DoesNotExist:
                oscar_address = UserAddress.objects.create(
                    line1 = address.line1,
                    line2 = address.line2,
                    line3 = address.line3,
                    line4 = address.locality,
                    state = address.state,
                    postcode = address.postcode,
                    country = Country.objects.get(iso_3166_1_a2=address.country),
                    user = instance.user
                )
                address.oscar_address = oscar_address
                address.save()
        # Clear out unused addresses
        user = instance.user
        user_addr = Address.objects.filter(user=user)
        for u in user_addr:
            if not u.profiles.all():
                u.oscar_address.delete()
                u.delete()
开发者ID:scottp-dpaw,项目名称:ledger,代码行数:63,代码来源:models.py

示例5: _create_user_social_auth

# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_social_auth [as 别名]
    def _create_user_social_auth(self, user):
        user_social_auth = UserSocialAuth.create_social_auth(user, user.email, 'email')
        user_social_auth.extra_data = {'email': [user.email]}
        user_social_auth.save()

        return user_social_auth
开发者ID:ropable,项目名称:ledger,代码行数:8,代码来源:admin.py


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