def create_account_view(request): if request.method == 'POST': form = CreateAccountForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/account/successful') form = CreateAccountForm return render(request, 'create_account.html', {'form': form})
def sign_up(request): if request.method == 'POST' and request.POST.get( 'password') == request.POST.get('rePassword'): form = CreateAccountForm(request.POST) if form.is_valid(): m = form.save() try: m.save() except: m = CreateAccount() return render( request, 'Sign_up.html', {'form': m }) # There will be a validation error on this page dateOpened = datetime.datetime.now() date = datetime.datetime.now() + datetime.timedelta(1) status = 'Activation Required' n = False while n == False: try: accNum = randint(1000000000, 9999999999) m.accNum = accNum m.save() n = True except: pass m.accNick = str(accNum) m.dateOpened = dateOpened m.status = status m.date = date salt = sha.new(str(random.random())).hexdigest()[:5] activation_key = sha.new(salt + str(m.userName)).hexdigest() key_expires = date mailer = Mail.objects.create(user=m.userName, email=m.email, activation_key=activation_key, date=key_expires) mailer.save() models.mail_activation(m.userName, m.email, activation_key) m.save() return HttpResponseRedirect('/Success1') else: m = CreateAccount() return render( request, 'Sign_up.html', {'form': m}) #There will be a validation error on this page else: m = CreateAccount() return render(request, 'Sign_up.html', {'form': m})
def create_account(request): if request.method == 'POST': create_account_form = CreateAccountForm(request.POST) if create_account_form.is_valid(): user, password = create_account_form.save() message = render_to_string('apple/email/account_created.txt', { 'user':user, 'password':password, 'admin_name':settings.ADMINS[0][0] }, context_instance=RequestContext(request)) if settings.PRODUCTION == True: user.email_user("Account Created", message, settings.DEFAULT_FROM_EMAIL) else: print message return HttpResponseRedirect(user.get_absolute_url()) else: create_account_form = CreateAccountForm() return render_to_response('apple/create_account.html', { 'create_account_form':create_account_form }, context_instance=RequestContext(request))
def sign_up(request): if request.method == 'POST' and request.POST.get('password') == request.POST.get('rePassword'): form = CreateAccountForm(request.POST) if form.is_valid(): m = form.save() try: m.save() except: m = CreateAccount() return render(request, 'Sign_up.html', {'form': m}) # There will be a validation error on this page dateOpened = datetime.datetime.now() date = datetime.datetime.now() + datetime.timedelta(1) status = 'Activation Required' n =False while n == False: try: accNum = randint(1000000000, 9999999999) m.accNum = accNum m.save() n = True except: pass m.accNick = str(accNum) m.dateOpened = dateOpened m.status = status m.date = date salt = sha.new(str(random.random())).hexdigest()[:5] activation_key = sha.new(salt + str(m.userName)).hexdigest() key_expires = date mailer = Mail.objects.create(user=m.userName,email=m.email,activation_key=activation_key,date=key_expires) mailer.save() models.mail_activation(m.userName, m.email, activation_key) m.save() return HttpResponseRedirect ('/Success1') else: m = CreateAccount() return render(request, 'Sign_up.html', {'form': m}) #There will be a validation error on this page else: m = CreateAccount() return render(request, 'Sign_up.html', {'form': m})