def register(request): if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" print request u_ajax = request.POST.get('username', None) print "u_ajax:%s"%u_ajax if u_ajax: response['Content-Type'] = "application/json" u = User.objects.filter(username=u_ajax) if u.exists(): response.write('{"info": u"username is exist","status": "n"}') # 用户已存在 return response form = RegisterForm(request.POST) print "form is :%s"%form if form.is_valid(): print "form is valid" cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] em = cd['smscode'] # nickname = cd['nickname'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() # initial={'photo_url': '/static/upload/default.png'} u = UserInformation(user=new_user, photo_url='/static/upload/default.png', email=em, abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) # return refresh_header(request, user_auth(request, username, pwd1, None)) #直接定向到首页 return HttpResponseRedirect(reverse('index1')) else: return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request))
def register(request): if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" u_ajax = request.POST.get('name', None) if u_ajax: response['Content-Type'] = "application/json" r_u = request.POST.get('param', None) u = User.objects.filter(username=r_u) if u.exists(): response.write('{"info": "用户已存在","status": "n"}') # 用户已存在 return response else: response.write('{"info": "用户可以使用","status": "y"}') return response form = RegisterForm(request.POST) if form.is_valid(): print "ddd" cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] smscode = cd['smscode'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() u = UserInformation(user=new_user, photo_url='/static/upload/default.png', abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) return HttpResponseRedirect(reverse('searchindex')) else: print "eeee" return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request))
def register(request): if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" u_ajax = request.POST.get('name', None) if u_ajax: response['Content-Type'] = "application/json" r_u = request.POST.get('param', None) u = User.objects.filter(username=r_u) if u.exists(): response.write('{"info": "用户已存在","status": "n"}') # 用户已存在 return response else: response.write('{"info": "用户可以使用","status": "y"}') return response form = RegisterForm(request.POST) if form.is_valid(): cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] #em = cd['email'] # nickname = cd['nickname'] smscode = cd['smscode'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response("reg_m.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() # initial={'photo_url': '/static/upload/default.png'} u = UserInformation(user=new_user, photo_url='/static/upload/default.png', abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) send_flow_all(username) p = re.compile('^13[4-9][0-9]{8}|^15[0,1,2,7,8,9][0-9]{8}|^18[2,7,8][0-9]{8}|^147[0-9]{8}|^178[0-9]{8}') p1 = re.compile('^18[0,1,9][0-9]{8}|^133[0-9]{8}|^153[0-9]{8}|^177[0-9]{8}') phone = username if p.match(str(phone)): flag1 = 1 elif p1.match(str(phone)): flag1 = 2 else: flag1 = 3 return render_to_response("reg_success_m.html", {'flag1':flag1}, context_instance=RequestContext(request)) else: return render_to_response("reg_m.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() return render_to_response("reg_m.html", {'form': form}, context_instance=RequestContext(request))
def active(request): if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" u_ajax = request.POST.get('name', None) if u_ajax: response['Content-Type'] = "application/json" r_u = request.POST.get('param', None) u = User.objects.filter(username=r_u) if u.exists(): response.write('{"info": "用户已存在","status": "n"}') # 用户已存在 return response else: response.write('{"info": "用户可以使用","status": "y"}') return response form = RegisterForm(request.POST) if form.is_valid(): cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] #em = cd['email'] # nickname = cd['nickname'] smscode = cd['smscode'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) if int(smscode) == 8765 and int(code) == 8765: f = True else: f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response( "active_reg.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() # initial={'photo_url': '/static/upload/default.png'} u = UserInformation(user=new_user, photo_url='/static/upload/default.png', abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) # return refresh_header(request, user_auth(request, username, pwd1, None)) #直接定向到首页 return HttpResponseRedirect(reverse('searchindex')) else: return render_to_response("active_reg.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() t = get_template('active_reg.html') content_html = t.render(RequestContext(request, {'form': form})) payload = { 'content_html': content_html, 'success': True, } return HttpResponse(json.dumps(payload), content_type="application/json")
def register(request): print "xxxddd" if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" u_ajax = request.POST.get('name', None) if u_ajax: response['Content-Type'] = "application/json" r_u = request.POST.get('param', None) u = User.objects.filter(username=r_u) if u.exists(): response.write('{"info": "用户已存在","status": "n"}') # 用户已存在 return response else: response.write('{"info": "用户可以使用","status": "y"}') return response form = RegisterForm(request.POST) if form.is_valid(): cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] em = cd['smscode'] # nickname = cd['nickname'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response( "signup.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() # initial={'photo_url': '/static/upload/default.png'} u = UserInformation(user=new_user, photo_url='/static/upload/default.png', email=em, abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) # return refresh_header(request, user_auth(request, username, pwd1, None)) #直接定向到首页 return HttpResponseRedirect(reverse('index1')) else: return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request))
def active(request): if request.method == 'POST': response = HttpResponse() response['Content-Type'] = "text/javascript" u_ajax = request.POST.get('name', None) if u_ajax: response['Content-Type'] = "application/json" r_u = request.POST.get('param', None) u = User.objects.filter(username=r_u) if u.exists(): response.write('{"info": "用户已存在","status": "n"}') # 用户已存在 return response else: response.write('{"info": "用户可以使用","status": "y"}') return response form = RegisterForm(request.POST) if form.is_valid(): cd = form.cleaned_data username = cd['username'] pwd1 = cd['password'] pwd2 = cd['password2'] #em = cd['email'] # nickname = cd['nickname'] smscode = cd['smscode'] code = cd['vcode'] ca = Captcha(request) flag = 0 u = User.objects.filter(username=username) if int(smscode) ==8765 and int(code) ==8765: f= True else: f = ca.check(code) if u.exists(): form.valiatetype(2) flag = 1 if pwd1 != pwd2: form.valiatetype(3) flag = 1 if not f: form.valiatetype(4) flag = 1 if flag == 1: return render_to_response("active_reg.html", {'form': form}, context_instance=RequestContext(request)) elif pwd1 == pwd2 and f: new_user = User.objects.create_user(username=username, password=pwd1) new_user.save() # initial={'photo_url': '/static/upload/default.png'} u = UserInformation(user=new_user, photo_url='/static/upload/default.png', abcdefg=pwd1) u.save() user = auth.authenticate(username=username, password=pwd1) auth.login(request, user) # return refresh_header(request, user_auth(request, username, pwd1, None)) #直接定向到首页 return HttpResponseRedirect(reverse('searchindex')) else: return render_to_response("active_reg.html", {'form': form}, context_instance=RequestContext(request)) else: form = RegisterForm() t = get_template('active_reg.html') content_html = t.render( RequestContext(request,{'form':form})) payload = { 'content_html': content_html, 'success': True, } return HttpResponse(json.dumps(payload), content_type="application/json")