本文整理汇总了Python中account.models.User.existPhoneNumber方法的典型用法代码示例。如果您正苦于以下问题:Python User.existPhoneNumber方法的具体用法?Python User.existPhoneNumber怎么用?Python User.existPhoneNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.existPhoneNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import existPhoneNumber [as 别名]
def register(self, request, *args, **kwargs):
phone_number = request.POST.get('phone_number')
if User.existPhoneNumber(phone_number, raise_exception=False):
return DefaultJsonResponse(code=appcodes.CODE_PHONE_IS_EXIST, message=R.String.PHONE_EXISTED)
if (isTestAccount(phone_number) or vertifySmsCode(request, SmsRecord.BUSINESS_TYPE_REGISTE)):
try:
# todo 测试
if request.POST.get('test', None):
user = User.objects.create(phone_number=phone_number)
user.role = user.HOTEL_PARTNER
user.save()
PartnerMember.objects.create(user=user)
from chaolife.serializers.user import UserSerializer
serializer = UserSerializer(user)
else:
member = CustomerMember.objects.create(phone_number)
user = member.user
serializer = CustomerUserSerializer(user, )
# end
token = Token.create_for_mobile_client(user, request.client_type)
# warn 测试
inviter = request.POST.get('inviter')
print('邀请者是{}'.format(inviter))
if inviter:
from account.invitation.service import invited_service
invited_service(inviter, user)
user.save()
user_data = {'user': serializer.data}
except BaseException as e:
# raise e
raise e
else:
# 都没出错
response = DefaultJsonResponse(data=user_data, code=appcodes.CODE_100_OK,
message=R.String.REGISTER_SUCCESS)
response['token'] = token
return response
else:
return DefaultJsonResponse(code=appcodes.CODE_SMS_ERROR, message=R.String.REGISTER_SMS_VERTIFY_FAILED)
示例2: get_login_sms
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import existPhoneNumber [as 别名]
def get_login_sms(self, request, phone_number, *args, **kwargs):
User.existPhoneNumber(phone_number)
sms_request = GetLoginSmsRequest(phone_number=phone_number)
sms_request.perform_request()
sms_record = sms_request.get_smsRecord()
return DefaultJsonResponse(message=R.String.SMS_SEND, data={'business_id': sms_record.business_id})