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


Python User.email方法代码示例

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


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

示例1: save_profile

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
def save_profile(backend, user, response, *args, **kwargs):
    data = {}
    data['is_social'] = True
    if backend.name == 'facebook':
        if kwargs['is_new']:
            data['first_name'] = kwargs['details']['first_name']
            data['last_name'] = kwargs['details']['last_name']
            data['email'] = kwargs['details']['email']
            register_form = SocialForm(data=data)
            if register_form.is_valid():
                new_user_instance = User.objects.filter(email=kwargs['details']['email'])
                if not new_user_instance:
                    new_user_instance = User()
                    new_user_instance.first_name = kwargs['details']['first_name']
                    new_user_instance.email = kwargs['details']['email']
                    new_user_instance.last_name = kwargs['details']['last_name']
                    new_user_instance.profile_status = 1
                    new_user_instance.save()
                else:
                    new_user_instance = User.objects.get(email=kwargs['details']['email'])
                return {
                    'is_new': True,
                    'user': new_user_instance
                }
            else:

                backend.strategy.session_set('social_data', data)

                return HttpResponseRedirect('/registration/')

    elif backend.name == 'google-oauth2':
        if kwargs['is_new']:
            data['first_name'] = kwargs['details']['first_name']
            data['last_name'] = kwargs['details']['last_name']
            data['email'] = kwargs['details']['email']
            register_form = SocialForm(data=data)
            if register_form.is_valid():
                new_user_instance = User.objects.filter(email=kwargs['details']['email'])
                if not new_user_instance:
                    new_user_instance = User()
                    new_user_instance.first_name = kwargs['details']['first_name']
                    new_user_instance.email = kwargs['details']['email']
                    new_user_instance.last_name = kwargs['details']['last_name']
                    new_user_instance.profile_status = 1
                    new_user_instance.save()
                else:
                    new_user_instance = User.objects.get(email=kwargs['details']['email'])
                return {
                    'is_new': True,
                    'user': new_user_instance
                }
            else:

                backend.strategy.session_set('social_data', data)

                return HttpResponseRedirect('/registration/')
开发者ID:peterkim139,项目名称:aaa,代码行数:58,代码来源:views.py

示例2: test_duplicate_email_check

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
	def test_duplicate_email_check(self):
		user = User()
		user.username = "test"
		user.email = "[email protected]"
		user.set_password("test")
		user.full_clean()
		user.save()

		with self.assertRaises(ValidationError):
			user2 = User()
			user2.username = "test2"
			user2.email = "[email protected]"
			user2.set_password("test")
			user2.full_clean()
			user2.save()
开发者ID:XFJH,项目名称:Shakal-NG,代码行数:17,代码来源:tests.py

示例3: authenticate

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
    def authenticate(self, token):
        response_profile = requests.get(
            'https://graph.facebook.com/me/',
            params={
                'access_token': token,
            }
        )

        facebook_profile = response_profile.json()

        if 'error' in facebook_profile:
            return None

        try:
            user = User.objects.get(facebook_id=facebook_profile.get('id'))
        except User.DoesNotExist:
            user = User(facebook_id=facebook_profile.get('id'))

        if facebook_profile.get('id') in settings.FACEBOOK_ADMINS:
            user.is_staff = True
            user.is_superuser = True

        user.username = facebook_profile.get('id')
        user.set_unusable_password()
        user.facebook_access_token = token
        user.email = facebook_profile.get('email', '')
        user.first_name = facebook_profile.get('first_name')
        user.last_name = facebook_profile.get('last_name')
        user.save()

        return user
开发者ID:DjangoLover,项目名称:djangodash2013,代码行数:33,代码来源:backends.py

示例4: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
def create_user(username=None, email=None, password=None):
    u = User()
    u.username = username
    u.email = email
    u.set_password(password)
    u.save()
    return True
开发者ID:ehazlett,项目名称:opencloud,代码行数:9,代码来源:test_helpers.py

示例5: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
def create_user():
    try:
        username = raw_input("Username: ").strip()
        email = raw_input("Email: ").strip()
        while True:
            password = getpass("Password: ")
            password_confirm = getpass(" (confirm): ")
            if password_confirm == password:
                break
            else:
                print("Passwords do not match... Try again...")
        u = User(username=username)
        u.email = email
        # check for org
        org = Organization.get_by_name("default")
        if not org:
            org = Organization()
            org.name = "default"
            org.owner = u.uuid
            org.save()
        u.organization = Organization.get_by_name("default").uuid
        u.set_password(password)
        u.add_role("admin")
        u.save()
        print("User created/updated successfully...")
    except KeyboardInterrupt:
        pass
开发者ID:ehazlett,项目名称:opencloud,代码行数:29,代码来源:application.py

示例6: post

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
    def post(self, request):
        
        form = RegistrationForm(data=request.POST)
        response = HttpResponseRedirect('/')
        if form.is_valid():
            user = User()
            year = request.POST['birthdate_year']
            month = request.POST['birthdate_month']
            day = request.POST['birthdate_day']
            date_of_birth = year+'-'+month+'-'+day
            user.birthday = date_of_birth
            user.email = form.cleaned_data['email']
            user.role = 'client'
            user.first_name = form.cleaned_data['first_name']
            user.phone_number = ''
            user.zip_code = form.cleaned_data['zip_code']
            user.last_name = form.cleaned_data['last_name']
            user.set_password(form.cleaned_data['password'])
            user.save()
            confirm_register_mail(request, user.email, user.first_name, user.last_name, user.zip_code)
            new_user = authenticate(email=form.cleaned_data['email'],
                                    password=form.cleaned_data['password'],
                                    )
            login(request, new_user)
            messages.success(request, "You have registered successfully.")
        else:
            response.set_cookie('registr_error', 'error')
            cache.set('registartion_error', RegistrationForm(request.POST))

        return response
开发者ID:peterkim139,项目名称:aaa,代码行数:32,代码来源:views.py

示例7: create

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
 def create(self, validated_data):
     user = User()
     user.set_password(validated_data["password"])
     user.email = validated_data['email']
     user.first_name = validated_data['first_name']
     user.last_name = validated_data['last_name']
     user.phone_number = validated_data['phone_number']
     return user
开发者ID:headphonesjones,项目名称:Blohaute,代码行数:10,代码来源:serializers.py

示例8: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
def create_user():
    user = User()
    user.username = request.form.get('username', None)
    user.first_name = request.form.get('first_name', '')
    user.last_name = request.form.get('last_name', '')
    user.email = request.form.get('email', '')
    user.account = request.form.get('account', None)
    user.set_password(request.form.get('password', ''))
    user.save()
    return redirect(url_for('accounts.users'))
开发者ID:ehazlett,项目名称:opencloud,代码行数:12,代码来源:views.py

示例9: test_creating_new_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
	def test_creating_new_user(self):
		user = User()
		user.username = "test"
		user.email = "[email protected]"
		user.set_password("test")
		user.full_clean()
		user.save()

		all_users = User.objects.all()
		self.assertEqual(len(all_users), 1)

		user_from_database = all_users[0]
		self.assertEquals(user_from_database, user)
开发者ID:XFJH,项目名称:Shakal-NG,代码行数:15,代码来源:tests.py

示例10: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import email [as 别名]
def create_user(request):
    if not request.method == 'POST':
        return HttpResponseNotAllowed(['POST'])

    post_params = json.loads(request.body)
    form = UserRegistrationForm(data=post_params)
    if form.is_valid():
        user = User()
        user.email = form.cleaned_data.get('email')
        user.set_password(form.cleaned_data.get('password'))
        with transaction.atomic():
            user.save()
            token = Token.create_token()
            user.token_set.add(token)

        logger.info("New user created. Email: %s", user.email)
        user_dict = user.to_dict()
        user_dict['access_token'] = token.token
        data = json.dumps(user_dict)
        return HttpResponse(data)
    else:
        logger.error("Invalid form to create new user. Errors: %s", form.errors)
        data = json.dumps(form.errors)
        return HttpResponseBadRequest(data)
开发者ID:ezy023,项目名称:marker-api,代码行数:26,代码来源:views.py


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