Private
Public Access
1
0

email confirmation for new coach users

This commit is contained in:
Sander Roosendaal
2021-03-31 10:26:11 +02:00
parent 51b085001d
commit ce22f51207

View File

@@ -733,6 +733,10 @@ def useractivate(request, uidb64, token):
d = {'first_name':user.first_name} d = {'first_name':user.first_name}
template = 'registeremail.html'
if user.rower.rowerplan == 'freecoach':
template = 'coachregisteremail.html'
send_template_email(from_address,[fullemail], send_template_email(from_address,[fullemail],
subject,'registeremail.html',d) subject,'registeremail.html',d)
@@ -742,13 +746,19 @@ def useractivate(request, uidb64, token):
message2 += fullemail + "\n" message2 += fullemail + "\n"
message2 += "User name: "+user.username message2 += "User name: "+user.username
if user.rower.rowerplan == 'freecoach':
subject2 = "New Free Coach User"
send_mail(subject2, message2, send_mail(subject2, message2,
'Rowsandall Server <info@rowsandall.com>', 'Rowsandall Server <info@rowsandall.com>',
['roosendaalsander@gmail.com']) ['roosendaalsander@gmail.com'])
messages.info(request,'Thank you for your email confirmation. Now you can login your account.') messages.info(request,'Thank you for your email confirmation. Now you can login to your account.')
url = '/login/' url = '/login/'
if user.rower.rowerplan == 'freecoach':
url+='?next=/rowers/me/teams'
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else:
return HttpResponse('Activation link is invalid!') return HttpResponse('Activation link is invalid!')
@@ -890,29 +900,28 @@ def freecoach_register_view(request):
# create default favorite charts # create default favorite charts
add_defaultfavorites(therower) add_defaultfavorites(therower)
# Create and send email # Create and send email
fullemail = first_name + " " + last_name + " " + "<" + email + ">" current_site = get_current_site(request)
subject = "Thank you for registering on rowsandall.com" mail_subject = 'Activate your account.'
from_address = 'Sander Roosendaal <info@rowsandall.com>' d = {
'user': theuser,
d = {'first_name':theuser.first_name} 'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(theuser.id)).decode(),
send_template_email(from_address,[fullemail], 'token': account_activation_token.make_token(theuser),
subject,'coachregisteremail.html',d) }
to_email = form.cleaned_data.get('email')
message = render_to_string('acc_activate_email.html', {
subject2 = "New Free Coach" 'user': theuser,
message2 = "New Free Coach registered.\n" 'domain': current_site.domain,
message2 += fullemail + "\n" 'uid': urlsafe_base64_encode(force_bytes(theuser.id)).decode(),
message2 += "User name: "+username 'token': account_activation_token.make_token(theuser),
})
send_mail(subject2, message2, to_email = form.cleaned_data.get('email')
'Rowsandall Server <info@rowsandall.com>', email = EmailMessage(
['roosendaalsander@gmail.com']) mail_subject, message, to=[to_email]
)
theuser = authenticate(username=username,password=password) email.send()
login(request,theuser) return HttpResponse('Please confirm your email address to complete the registration')
return HttpResponseRedirect(nextpage) return HttpResponseRedirect(nextpage)