本文整理汇总了Python中accounts.models.User.profile_status方法的典型用法代码示例。如果您正苦于以下问题:Python User.profile_status方法的具体用法?Python User.profile_status怎么用?Python User.profile_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.User
的用法示例。
在下文中一共展示了User.profile_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_profile
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import profile_status [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/')