def process_independent_student_signup_form(request, data): email = data["email"] independent_students = Student.objects.filter(class_field=None) if email and independent_students.filter(new_user__email=email).exists(): email_message = email_messages.userAlreadyRegisteredEmail( request, email) send_email( NOTIFICATION_EMAIL, [email], email_message["subject"], email_message["message"], ) return render(request, "portal/email_verification_needed.html") student = Student.objects.independentStudentFactory( username=data["username"], name=data["name"], email=data["email"], password=data["password"], ) if _newsletter_ticked(data): user = student.new_user add_to_salesforce(user.first_name, user.last_name, user.email) send_verification_email(request, student.new_user) return render(request, "portal/email_verification_needed.html", {"user": student.new_user})
def process_signup_form(request, data): email = data['teacher_email'] teacher = None if email and Teacher.objects.filter(new_user__email=email).exists(): email_message = emailMessages.userAlreadyRegisteredEmail( request, email) send_email(NOTIFICATION_EMAIL, [email], email_message['subject'], email_message['message']) else: teacher = Teacher.objects.factory( title=data['teacher_title'], first_name=data['teacher_first_name'], last_name=data['teacher_last_name'], email=data['teacher_email'], password=data['teacher_password']) if _newsletter_ticked(data): user = teacher.user.user add_to_salesforce(user.first_name, user.last_name, user.email) send_verification_email(request, teacher.user.user) if teacher: return render(request, 'portal/email_verification_needed.html', {'user': teacher.user.user}) else: return render(request, 'portal/email_verification_needed.html')
def process_independent_student_signup_form(request, data): email = data["email"] independent_students = Student.objects.filter(class_field=None) if email and independent_students.filter(new_user__email=email).exists(): email_message = email_messages.userAlreadyRegisteredEmail(request, email) send_email( NOTIFICATION_EMAIL, [email], email_message["subject"], email_message["message"], ) return render(request, "portal/email_verification_needed.html") student = Student.objects.independentStudentFactory( username=data["username"], name=data["name"], email=data["email"], password=data["password"], ) if _newsletter_ticked(data): user = student.new_user add_to_salesforce(user.first_name, user.last_name, user.email) send_verification_email(request, student.new_user) return render( request, "portal/email_verification_needed.html", {"user": student.new_user} )
def process_signup_form(request, data): email = data["teacher_email"] teacher = None if email and Teacher.objects.filter(new_user__email=email).exists(): email_message = email_messages.userAlreadyRegisteredEmail(request, email) send_email( NOTIFICATION_EMAIL, [email], email_message["subject"], email_message["message"], ) else: teacher = Teacher.objects.factory( title=data["teacher_title"], first_name=data["teacher_first_name"], last_name=data["teacher_last_name"], email=data["teacher_email"], password=data["teacher_password"], ) if _newsletter_ticked(data): user = teacher.user.user add_to_salesforce(user.first_name, user.last_name, user.email) send_verification_email(request, teacher.user.user) if teacher: return render( request, "portal/email_verification_needed.html", {"user": teacher.user.user}, ) else: return render(request, "portal/email_verification_needed.html")
def change_email(request, token): verifications = EmailVerification.objects.filter(token=token) if has_verification_failed(verifications): return render(request, 'portal/email_verification_failed.html') verification = verifications[0] verification.verified = True verification.save() user = verification.user if verification.email: # verifying change of email address user.email = verification.email user.save() user.email_verifications.exclude(email=user.email).delete() messages.success(request, 'Your email address was successfully verified, please log in.') # copy newly verified user to secure salesforce db add_to_salesforce(user) if hasattr(user.userprofile, 'teacher'): return HttpResponseRedirect(reverse_lazy('dashboard')) # default to homepage if something goes wrong return HttpResponseRedirect(reverse_lazy('home'))
def process_newsletter_form(request): if request.method == 'POST': next = request.POST.get('URL') if not None else '/' newsletter_form = NewsletterForm(data=request.POST) if newsletter_form.is_valid(): user_email = newsletter_form.cleaned_data['email'] add_to_salesforce("", "", user_email) messages.success(request, 'Thank you for signing up!') return HttpResponseRedirect(next) messages.error(request, 'Invalid email address. Please try again.', extra_tags='sub-nav--warning') return HttpResponseRedirect(next) return HttpResponse(status=405)
def process_newsletter_form(request): if request.method == "POST": newsletter_form = NewsletterForm(data=request.POST) if newsletter_form.is_valid(): user_email = newsletter_form.cleaned_data["email"] add_to_salesforce("", "", user_email) messages.success(request, "Thank you for signing up!") return HttpResponseRedirect(reverse_lazy("home")) messages.error( request, "Invalid email address. Please try again.", extra_tags="sub-nav--warning", ) return HttpResponseRedirect(reverse_lazy("home")) return HttpResponse(status=405)
def process_newsletter_form(request): if request.method == "POST": next = request.POST.get("URL") if not None else "/" newsletter_form = NewsletterForm(data=request.POST) if newsletter_form.is_valid(): user_email = newsletter_form.cleaned_data["email"] add_to_salesforce("", "", user_email) messages.success(request, "Thank you for signing up!") return HttpResponseRedirect(next) messages.error( request, "Invalid email address. Please try again.", extra_tags="sub-nav--warning", ) return HttpResponseRedirect(next) return HttpResponse(status=405)
def process_student_signup_form(request, data): student = Student.objects.independentStudentFactory( username=data['username'], name=data['name'], email=data['email'], password=data['password']) email_supplied = (data['email'] != '') if email_supplied: if _newsletter_ticked(data): user = student.new_user add_to_salesforce(user.first_name, user.last_name, user.email) send_verification_email(request, student.new_user) return render(request, 'portal/email_verification_needed.html', {'user': student.new_user}) return render(request, 'portal/play/student_details.html')