def mdl_register(request): form = RegisterForm() # import recaptcha validate function from cms.recaptcha import recaptcha_valdation, get_recaptcha_context #reCAPTCHA Site key context = get_recaptcha_context() if request.method == "POST": # verify recaptcha #recaptcha_result = recaptcha_valdation(request) form = RegisterForm(request.POST) #if recaptcha_result and form.is_valid(): if form.is_valid(): #Email exits try: user = MdlUser.objects.filter( email=request.POST['email']).first().id messages.success( request, "Email : " + request.POST['email'] + " already registered on this website. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login" ) except Exception as e: mdluser = MdlUser() mdluser.auth = 'manual' mdluser.institution = form.cleaned_data['college'] mdluser.gender = form.cleaned_data['gender'] mdluser.firstname = form.cleaned_data['firstname'].upper() mdluser.lastname = form.cleaned_data['lastname'].upper() mdluser.email = form.cleaned_data['email'].lower() mdluser.username = mdluser.email mdluser.password = encript_password( form.cleaned_data['password']) mdluser.confirmed = 1 mdluser.mnethostid = 1 mdluser.save() mdluser = MdlUser.objects.get(email=mdluser.email) get_or_create_user(mdluser, form.cleaned_data['password']) messages.success( request, "User " + form.cleaned_data['firstname'] + " " + form.cleaned_data['lastname'] + " Created!. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login" ) return HttpResponseRedirect('/participant/register/') context['form'] = form context.update(csrf(request)) return render(request, 'mdl/templates/register.html', context)
def account_register(request): # import recaptcha validate function from cms.recaptcha import recaptcha_valdation, get_recaptcha_context # reCAPTCHA Site key context = get_recaptcha_context() if request.method == 'POST': # verify recaptcha recaptcha_result = recaptcha_valdation(request) form = RegisterForm(request.POST) if recaptcha_result and form.is_valid(): username = request.POST['username'] password = request.POST['password'] email = request.POST['email'] first_name = request.POST['first_name'] last_name = request.POST['last_name'] phone = request.POST['phone'] user = User.objects.create_user(username, email, password) user.first_name = first_name user.last_name = last_name user.is_active = False user.save() create_profile(user, phone) send_registration_confirmation(user) messages.success( request, "Thank you for registering.\ Please confirm your registration by clicking on the activation link which has been sent to your registered email %s.<br>\ In case if you do not receive any activation mail kindly verify and activate your account from below link :<br>\ <a href='http://spoken-tutorial.org/accounts/verify/'>http://spoken-tutorial.org/accounts/verify/</a>" % (email)) return HttpResponseRedirect('/') context['form'] = form return render_to_response('cms/templates/register.html', context, context_instance=RequestContext(request)) else: form = RegisterForm() context['form'] = form context.update(csrf(request)) return render_to_response('cms/templates/register.html', context)
def account_register(request): # import recaptcha validate function from cms.recaptcha import recaptcha_valdation, get_recaptcha_context # reCAPTCHA Site key context = get_recaptcha_context() if request.method == 'POST': # verify recaptcha recaptcha_result = recaptcha_valdation(request) form = RegisterForm(request.POST) if recaptcha_result and form.is_valid(): username = request.POST['username'] password = request.POST['password'] email = request.POST['email'] first_name = request.POST['first_name'] last_name = request.POST['last_name'] phone = request.POST['phone'] user = User.objects.create_user(username, email, password) user.first_name = first_name user.last_name = last_name user.is_active = False user.save() create_profile(user, phone) send_registration_confirmation(user) messages.success(request, "Thank you for registering.\ Please confirm your registration by clicking on the activation link which has been sent to your registered email %s.<br>\ In case if you do not receive any activation mail kindly verify and activate your account from below link :<br>\ <a href='http://spoken-tutorial.org/accounts/verify/'>http://spoken-tutorial.org/accounts/verify/</a>" % (email)) return HttpResponseRedirect('/') context['form'] = form return render_to_response('cms/templates/register.html', context, context_instance = RequestContext(request)) else: form = RegisterForm() context['form'] = form context.update(csrf(request)) return render_to_response('cms/templates/register.html', context)
def mdl_register(request): form = RegisterForm() # import recaptcha validate function from cms.recaptcha import recaptcha_valdation, get_recaptcha_context #reCAPTCHA Site key context = get_recaptcha_context() if request.method == "POST": # verify recaptcha recaptcha_result = recaptcha_valdation(request) form = RegisterForm(request.POST) if recaptcha_result and form.is_valid(): #Email exits try: user = MdlUser.objects.filter(email=request.POST['email']).first().id messages.success(request, "Email : "+request.POST['email']+" already registered on this website. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login") except Exception, e: mdluser = MdlUser() mdluser.auth = 'manual' mdluser.institution = form.cleaned_data['college'] mdluser.gender = form.cleaned_data['gender'] mdluser.firstname = form.cleaned_data['firstname'].upper() mdluser.lastname = form.cleaned_data['lastname'].upper() mdluser.email = form.cleaned_data['email'].lower() mdluser.username = mdluser.email mdluser.password = encript_password(form.cleaned_data['password']) mdluser.confirmed = 1 mdluser.mnethostid = 1 mdluser.save() mdluser = MdlUser.objects.get(email=mdluser.email) get_or_create_user(mdluser, form.cleaned_data['password']) messages.success(request, "User " + form.cleaned_data['firstname'] +" "+form.cleaned_data['lastname']+" Created!. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login") return HttpResponseRedirect('/participant/register/')