def signup(request): if request.method == 'POST': signupform=SignUpForm(request.POST) form=ProfileForm(request.POST,request.FILES) if form.is_valid(): user = signupform.save(commit=False) user.is_active = False user.save() user.refresh_from_db() user.profile.dob=form.cleaned_data.get('dob') user.profile.gender=form.cleaned_data.get('gender') user.profile.mobile=form.cleaned_data.get('mobile') user.profile.aadhar_no=form.cleaned_data.get('aadhar_no') user.profile.acertificate=form.cleaned_data.get('acertificate') user.profile.address=form.cleaned_data.get('address') user.profile.bcertificate=form.cleaned_data.get('bcertificate') user.profile.experience=form.cleaned_data.get('experience') user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string('account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: signupform = SignUpForm() form=ProfileForm return render(request, 'signup.html', {'form': signupform,'profile_form':form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() # load the profile instance created by the signal user.profile.birth_date = form.cleaned_data.get('birth_date') user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') data = request.POST.copy() ausername = str(form.cleaned_data.get('username')) apassword = str(form.cleaned_data.get('password1')) aname = str(form.cleaned_data.get('first_name')) adept = str(form.cleaned_data.get('Department')) aemail = str(form.cleaned_data.get('email')) aphone = str(form.cleaned_data.get('phone_number')) data = { "ausername": ausername, "apassword": apassword, "aname": aname, "adept": adept, "aemail": aemail, "aphone": aphone } resp = requests.post( 'https://outpassapp.herokuapp.com/adminregister', data) message = resp.json() if (message['message'] == "Admin of given dept already exists"): return render(request, 'registration/signup.html', { 'form': form, 'message': message }) else: return redirect('home') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def signup(request): """USED_CASE_2""" if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal user.profile.birth_date = form.cleaned_data.get('birth_date') user.profile.email = form.cleaned_data.get('email') user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() raw_id = form.cleaned_data.get('email') server.login("*****@*****.**", "mxfpjjvokodkvzcu") msg = ( "Welcome to Kraysoft assignment tester site.\r\n\nYour registration is succesfully complete.\r\n Please save your password carefully: %s\r\n\r\n" % (raw_password)) server.sendmail("*****@*****.**", raw_id, msg) server.quit() login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() Profile.update_user_profile(user, 'biology', form.cleaned_data['email']) bmm.update_body_measurements(user, form.cleaned_data['height'], form.cleaned_data['weight']) current_site = get_current_site(request) subject = 'Activate Your MediCare Account' message = render_to_string( 'account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) from_email = settings.EMAIL_HOST_USER user.email_user(subject, message, from_email) return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup_staff(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.is_staff = True user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string( 'account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) send_mail( subject=subject, message=message, from_email='*****@*****.**', recipient_list=[user.email], ) return redirect('account_activation_email') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string( 'account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes( user.pk)).decode('utf-8'), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string('account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def signup(request): if request.method == 'POST': #form = UserCreationForm(request.POST) form = SignUpForm(request.POST, request.FILES) if form.is_valid(): #handle_uploaded_file(request.FILES['file']) form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') return redirect('home') else: form = SignUpForm() #form = UserCreationForm() return render(request, 'registration/signup.html', { 'form': form })
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() # load the profile instance created by the signal user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() # загружается инстанс профиля, созданный "сигналом" user.profile.email = form.cleaned_data.get('email') user.save() # юзер сохраняется, когда компилятор доходит до этой строчки raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.first_name = form.cleaned_data.get('password1') post.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('https://m.facebook.com/groups/bidformedgte/') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def students(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() ausername = str(form.cleaned_data.get('username')) apassword = str(form.cleaned_data.get('password1')) aname = str(form.cleaned_data.get('first_name')) + str( form.cleaned_data.get('last_name')) adept = str(form.cleaned_data.get('Department')) aemail = str(form.cleaned_data.get('email')) template = render_to_string( 'email_template.html', { 'name': aname, 'uname': ausername, 'password': apassword, 'fname': val }) email = EmailMessage('Password', template, settings.EMAIL_HOST_USER, [aemail]) email.fail_silently = False email.send() det = { "sname": aname, "pword": apassword, "aid": j, "branch": adept, "roll": ausername, "email": aemail } addstudent = requests.post( "https://antirag-api.herokuapp.com/add-student", det, headers={'Authorization': f'Bearer {l}'}) return render(request, 'registration/helloworld.html') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string( 'account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) # PArt above this line does not work on localhost and prints to console to = user.email gmail_user = '******' gmail_pwd = 'cubingsaviour' smtpserver = smtplib.SMTP("smtp.gmail.com", 587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(gmail_user, gmail_pwd) header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n' print header msg = header + '\n this is test msg from mkyong.com \n\n' msg += "<body> <p> Rara </p> </body>" msg = message smtpserver.sendmail(gmail_user, to, msg) print 'done!' smtpserver.close return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def get(request): form = SignUpForm() user = User.objects.all() print(user) args = {'form': form, 'user':user} return render(request, 'registration/profile.html', args)