def validate_email_and_phone(request): username = request.POST['username'] email = request.POST['email'] phone = request.POST['phone'] errs = {} if MHLUser.objects.filter(Q(username=username)): errs['err1'] = 1 # When refine register feature, remove following 3 lines to a common function in utils. for url in settings.CHECKUSERNAME_URL: if check_username_another_server(username, url, 0): errs['err1'] = 1 if MHLUser.objects.filter(Q(email=email)): errs['err2'] = 1 if settings.CALL_ENABLE and phone and MHLUser.objects.filter(Q(mobile_phone=phone)): errs['err3'] = 1 return HttpResponse(json.dumps(errs))
def validate_email_and_phone(request): username = request.POST['username'] email = request.POST['email'] phone = request.POST['phone'] errs = {} if MHLUser.objects.filter(Q(username=username)): errs['err1'] = 1 # When refine register feature, remove following 3 lines to a common function in utils. for url in settings.CHECKUSERNAME_URL: if check_username_another_server(username, url, 0): errs['err1'] = 1 if MHLUser.objects.filter(Q(email=email)): errs['err2'] = 1 if settings.CALL_ENABLE and phone and MHLUser.objects.filter( Q(mobile_phone=phone)): errs['err3'] = 1 return HttpResponse(json.dumps(errs))
def check_username_another_server(self, url, times): user_name = self.cleaned_data['username'] if check_username_another_server(user_name, url, times): raise forms.ValidationError(MSG_USERNAME_EXIST)
def check_username_another_server(self, url, times): user_name = self.cleaned_data['username'] if check_username_another_server(user_name, url, times): raise forms.ValidationError(MSG_USERNAME_EXIST)