Private
Public Access
1
0

registration form (just copy paste of user registration)

This commit is contained in:
Sander Roosendaal
2019-05-07 09:35:17 +02:00
parent 59e5fd6521
commit 01f108e9c3
6 changed files with 135 additions and 2 deletions

View File

@@ -566,6 +566,83 @@ def rower_register_view(request):
{'form':form,
'next':nextpage,})
# User registration
def freecoach_register_view(request):
nextpage = request.GET.get('next','/rowers/me/teams/')
if nextpage == '':
nextpage = '/rowers/me/teams/'
if request.method == 'POST':
#form = RegistrationFormUniqueEmail(request.POST)
form = RegistrationFormSex(request.POST)
if form.is_valid():
first_name = form.cleaned_data['first_name']
last_name = form.cleaned_data['last_name']
email = form.cleaned_data['email']
password = form.cleaned_data['password1']
username = form.cleaned_data['username']
sex = form.cleaned_data['sex']
birthdate = form.cleaned_data['birthdate']
weightcategory = form.cleaned_data['weightcategory']
adaptiveclass = form.cleaned_data['adaptiveclass']
nextpage = request.POST['next']
theuser = User.objects.create_user(username,password=password)
theuser.first_name = first_name
theuser.last_name = last_name
theuser.email = email
theuser.save()
birthdate = birthdate.replace(tzinfo=None)
therower = Rower(user=theuser,sex=sex,birthdate=birthdate,
weightcategory=weightcategory,
adaptiveclass=adaptiveclass,
rowerplan='freecoach')
therower.save()
# create default favorite charts
add_defaultfavorites(therower)
# Create and send email
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
subject = "Thank you for registering on rowsandall.com"
from_address = 'Sander Roosendaal <info@rowsandall.com>'
d = {'first_name':theuser.first_name}
send_template_email(from_address,[fullemail],
subject,'registeremail.html',d)
subject2 = "New Free Coach"
message2 = "New Free Coach registered.\n"
message2 += fullemail + "\n"
message2 += "User name: "+username
send_mail(subject2, message2,
'Rowsandall Server <info@rowsandall.com>',
['roosendaalsander@gmail.com'])
theuser = authenticate(username=username,password=password)
login(request,theuser)
return HttpResponseRedirect(nextpage)
else:
return render(request,
"freecoach_registration_form.html",
{'form':form,
'next':nextpage,})
else:
form = RegistrationFormSex()
return render(request,
"freecoach_registration_form.html",
{'form':form,
'next':nextpage,})
@login_required()
def transactions_view(request):
if not request.user.is_staff: