def register_view(request): user = request.user if user.is_authenticated: return redirect('index') context = {} if request.POST: form = RegistrationForm(request.POST) if form.is_valid(): form.save() email = form.cleaned_data.get('email') raw_password = form.cleaned_data.get('password1') user = authenticate(email=email, password=raw_password) login(request, user) return redirect('index') else: context['registration_form'] = form else: form = RegistrationForm() context['registration_form'] = form return render(request, 'register.html', context)
def signup_view(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('/login/loginpage') else: form = RegistrationForm() return render(request,'login/signup.html',{'form':form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save(request) return redirect("/home") else: form = RegistrationForm() args = {'form': form} return render(request, 'account/register.html', args)
def signup(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect(reverse('index-home')) else: args = {'form': form} return render(request, 'login/signup.html', args) else: form = RegistrationForm() args = {'form': form} return render(request, 'login/signup.html', args)
def register_user_view(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() messages.success( request, 'You have successfully registered. Please login.') return render(request, 'login/login.html') args = {} args.update(csrf(request)) args['form'] = RegistrationForm() print args return render(request, 'login/register.html', args)
def register(request): if request.method == 'POST': form_1 = RegistrationForm(request.POST) form_2 = UserProfileForm(request.POST) if form_1.is_valid() and form_2.is_valid(): new_user = form_1.save(commit=False) new_user.set_password(form_1.cleaned_data['password1']) new_user.save() UserProfile.objects.create(user=new_user, USN=form_2.cleaned_data['USN'], year=form_2.cleaned_data['year'], sem=form_2.cleaned_data['sem'], phone=form_2.cleaned_data['phone']) #subject = 'Thank you for registering with Book-Share' #message = 'Dear User,\n\n Hope you take the best advantage of UVCE Book-share platform . Have a nice time !\n\n Thank You' #from_email = settings.EMAIL_HOST_USER #to_list = [save_1.email] #send_mail(subject,message,from_email,to_list,fail_silently=True) messages.success(request, 'Thank you for registering ! Login Here ') return redirect('/login/') else: form_1 = RegistrationForm() form_2 = UserProfileForm() args = {'form_1': form_1, 'form_2': form_2} return render(request, 'account/register.html', args)
def register(request): if request.method == 'POST': form = RegistrationForm(data=request.POST) if form.is_valid(): form.save() return redirect('..') # return render(request, 'rsvp/home.html',{}) # HttpResponseRedirect('/rsvp/') else: form = RegistrationForm() args = {'form': form} return render(request, 'login/reg_form.html', args) else: form = RegistrationForm() args = {'form': form} return render(request, 'login/reg_form.html', args)
def registration(request): print "Registering" # Like before, get the request's context. context = RequestContext(request) # A boolean value for telling the template whether the registration was successful. # Set to False initially. Code changes value to True when registration succeeds. registered = False # If it's a HTTP POST, we're interested in processing form data. if request.method == 'POST': print "POST request" user_form = RegistrationForm(request.POST) # If the two forms are valid... if user_form.is_valid(): print "Is valid" # Save the user's form data to the database. user = user_form.save() print "Saved form" # Now we hash the password with the set_password method. # Once hashed, we can update the user object. user.set_password(user.password) user.is_active = False print "Saving user" user.save() #Create And Send User Activation Email. confirmation_code = ''.join( random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for x in range(33)) print "adding confirmation code to user" p = UserProfile(user=user, confirmation_code=confirmation_code) p.save() title = "Textile Fabric Consultants, Inc. Account Activation" content = "Someone has recently registered at Textilefabric.com. We hope it was you. If so, please follow the link below. If not please disregard this email.\n" + "theftp.dyndns.org:8000/login/activate/" + str( p.confirmation_code) + "/" + user.username send_mail(title, content, '*****@*****.**', [user.email], fail_silently=False) #Update our variable to tell the template registration was successful. registered = True print "sent email" # Invalid form or forms - mistakes or something else? # Print problems to the terminal. # They'll also be shown to the user. else: print user_form.errors # Not a HTTP POST, so we render our form using two ModelForm instances. # These forms will be blank, ready for user input. form = RegistrationForm(request.POST) form_html = render_crispy_form(form) result = {'success': registered, 'form_html': form_html} return result
def register_user_view(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'You have successfully registered. Please login.') return render(request, 'login/login.html') args ={} args.update(csrf(request)) args['form'] = RegistrationForm() print args return render(request, 'login/register.html', args)
def register(request): ''' registers users ''' # redirect user to home if user is already signed in if request.user.is_authenticated: extra_context = { 'extra_context': { 'message': 'True', 'message_title': 'Warning: ', 'message_text': 'You are already logged in' } } return render(request, 'shop/home.html', extra_context) # if request is post if request.method == 'POST': # get the post form form = RegistrationForm(request.POST) # check to see if the form is valid if form.is_valid(): # if it is valid, save and redirect to home form.save() # TODO: Keep logged in after registered? extra_context = { 'extra_context': { "page": "home", 'message': 'True', 'message_title': 'Register: ', 'message_text': 'You have successfully created an account' } } return render(request, 'shop/home.html', extra_context) else: # form is not valid and return form with error args = {'form': form} return render(request, 'login/register.html', args) # if request is not post, user probably wants the webpage with a empty form else: # give user clean register form form = RegistrationForm() args = {'form': form} return render(request, 'login/register.html', args)
def registration(request): print "Registering" # Like before, get the request's context. context = RequestContext(request) # A boolean value for telling the template whether the registration was successful. # Set to False initially. Code changes value to True when registration succeeds. registered = False # If it's a HTTP POST, we're interested in processing form data. if request.method == 'POST': print "POST request" user_form = RegistrationForm(request.POST) # If the two forms are valid... if user_form.is_valid(): print "Is valid" # Save the user's form data to the database. user = user_form.save() print "Saved form" # Now we hash the password with the set_password method. # Once hashed, we can update the user object. user.set_password(user.password) user.is_active = False print "Saving user" user.save() #Create And Send User Activation Email. confirmation_code = ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for x in range(33)) print "adding confirmation code to user" p = UserProfile(user=user, confirmation_code=confirmation_code) p.save() title = "Textile Fabric Consultants, Inc. Account Activation" content = "Someone has recently registered at Textilefabric.com. We hope it was you. If so, please follow the link below. If not please disregard this email.\n" +"theftp.dyndns.org:8000/login/activate/" + str(p.confirmation_code) + "/" + user.username send_mail(title, content, '*****@*****.**', [user.email], fail_silently=False) #Update our variable to tell the template registration was successful. registered = True print "sent email" # Invalid form or forms - mistakes or something else? # Print problems to the terminal. # They'll also be shown to the user. else: print user_form.errors # Not a HTTP POST, so we render our form using two ModelForm instances. # These forms will be blank, ready for user input. form = RegistrationForm(request.POST) form_html = render_crispy_form(form) result = {'success': registered, 'form_html': form_html} return result
def register(request): # TODO: change redirects to render with messages if request.user.is_authenticated: extra_context = { 'extra_context': { 'message': 'True', 'message_title': 'Warning: ', 'message_text': 'You are already logged in' } } return render(request, 'login/home.html', extra_context) if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('home') else: form = RegistrationForm() args = {'form': form} return render(request, 'login/register.html', args)
def registration(request): if not request.user.is_authenticated: if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = form.save() # user = authenticate(request, # username=form.cleaned_data['user_name'], # password=form.cleaned_data['password1'], # ) # if user is not None: login(request, user) return redirect('mychar:edit') else: form = RegistrationForm() return render(request, 'login/register.html', { 'form': form, }) else: return redirect('home:index')