added birth date & sex to user model
This commit is contained in:
@@ -354,6 +354,7 @@ class RegistrationFormTermsOfService(RegistrationForm):
|
|||||||
tos = forms.BooleanField(widget=forms.CheckboxInput,
|
tos = forms.BooleanField(widget=forms.CheckboxInput,
|
||||||
label='I have read and agree to the Terms of Service',
|
label='I have read and agree to the Terms of Service',
|
||||||
error_messages={'required': "You must agree to the terms to register"})
|
error_messages={'required': "You must agree to the terms to register"})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
||||||
@@ -370,6 +371,35 @@ class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
|||||||
raise forms.ValidationError("This email address is already in use. Please supply a different email address.")
|
raise forms.ValidationError("This email address is already in use. Please supply a different email address.")
|
||||||
return self.cleaned_data['email']
|
return self.cleaned_data['email']
|
||||||
|
|
||||||
|
class RegistrationFormSex(RegistrationFormUniqueEmail):
|
||||||
|
sexcategories = (
|
||||||
|
('female','female'),
|
||||||
|
('male','male'),
|
||||||
|
('not specified','not specified'),
|
||||||
|
)
|
||||||
|
|
||||||
|
weightcategories = (
|
||||||
|
('hwt','heavy-weight'),
|
||||||
|
('lwt','light-weight'),
|
||||||
|
)
|
||||||
|
|
||||||
|
birthdate = forms.DateTimeField(widget=SelectDateWidget(
|
||||||
|
years=range(timezone.now().year-100,timezone.now().year-10)),
|
||||||
|
initial = datetime.date(year=1970,
|
||||||
|
month=4,
|
||||||
|
day=15))
|
||||||
|
|
||||||
|
sex = forms.ChoiceField(required=True,
|
||||||
|
choices=sexcategories,
|
||||||
|
initial='not specified',
|
||||||
|
label='Sex')
|
||||||
|
|
||||||
|
weightcategory = forms.ChoiceField(label='Weight Category',
|
||||||
|
choices=weightcategories)
|
||||||
|
|
||||||
|
# def __init__(self, *args, **kwargs):
|
||||||
|
# self.fields['sex'].initial = 'not specified'
|
||||||
|
|
||||||
# Time field supporting microseconds. Not used, I believe.
|
# Time field supporting microseconds. Not used, I believe.
|
||||||
class MyTimeField(forms.TimeField):
|
class MyTimeField(forms.TimeField):
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from django import forms
|
|||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.forms.widgets import SplitDateTimeWidget
|
from django.forms.widgets import SplitDateTimeWidget
|
||||||
|
from django.forms.extras.widgets import SelectDateWidget
|
||||||
from django.forms.formsets import BaseFormSet
|
from django.forms.formsets import BaseFormSet
|
||||||
from datetimewidget.widgets import DateTimeWidget
|
from datetimewidget.widgets import DateTimeWidget
|
||||||
from django.core.validators import validate_email
|
from django.core.validators import validate_email
|
||||||
@@ -210,6 +211,12 @@ class Rower(models.Model):
|
|||||||
('lwt','light-weight'),
|
('lwt','light-weight'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sexcategories = (
|
||||||
|
('male','male'),
|
||||||
|
('female','female'),
|
||||||
|
('not specified','not specified'),
|
||||||
|
)
|
||||||
|
|
||||||
stravatypes = (
|
stravatypes = (
|
||||||
('Ride','Ride'),
|
('Ride','Ride'),
|
||||||
('Kitesurf','Kitesurf'),
|
('Kitesurf','Kitesurf'),
|
||||||
@@ -257,6 +264,11 @@ class Rower(models.Model):
|
|||||||
max_length=30,
|
max_length=30,
|
||||||
choices=weightcategories)
|
choices=weightcategories)
|
||||||
|
|
||||||
|
sex = models.CharField(default="not specified",
|
||||||
|
max_length=30,
|
||||||
|
choices=sexcategories)
|
||||||
|
|
||||||
|
birthdate = models.DateField(null=True,blank=True)
|
||||||
# Power Zone Data
|
# Power Zone Data
|
||||||
ftp = models.IntegerField(default=226,verbose_name="Functional Threshold Power")
|
ftp = models.IntegerField(default=226,verbose_name="Functional Threshold Power")
|
||||||
|
|
||||||
@@ -939,10 +951,17 @@ class RowerPowerZonesForm(ModelForm):
|
|||||||
class AccountRowerForm(ModelForm):
|
class AccountRowerForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Rower
|
model = Rower
|
||||||
fields = ['weightcategory','getemailnotifications',
|
fields = ['sex','birthdate','weightcategory','getemailnotifications',
|
||||||
'defaulttimezone','showfavoritechartnotes',
|
'defaulttimezone','showfavoritechartnotes',
|
||||||
'defaultlandingpage']
|
'defaultlandingpage']
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
'birthdate': SelectDateWidget(
|
||||||
|
years=range(
|
||||||
|
timezone.now().year-100,timezone.now().year-10)),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
email = self.cleaned_data.get('email')
|
email = self.cleaned_data.get('email')
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ from rowers.forms import (
|
|||||||
SummaryStringForm,IntervalUpdateForm,StrokeDataForm,
|
SummaryStringForm,IntervalUpdateForm,StrokeDataForm,
|
||||||
StatsOptionsForm,PredictedPieceForm,DateRangeForm,DeltaDaysForm,
|
StatsOptionsForm,PredictedPieceForm,DateRangeForm,DeltaDaysForm,
|
||||||
EmailForm, RegistrationForm, RegistrationFormTermsOfService,
|
EmailForm, RegistrationForm, RegistrationFormTermsOfService,
|
||||||
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
|
RegistrationFormUniqueEmail,RegistrationFormSex,
|
||||||
|
CNsummaryForm,UpdateWindForm,
|
||||||
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
||||||
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
|
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
|
||||||
TrendFlexModalForm,WorkoutSplitForm,WorkoutJoinParamForm,
|
TrendFlexModalForm,WorkoutSplitForm,WorkoutJoinParamForm,
|
||||||
@@ -772,20 +773,25 @@ def add_defaultfavorites(r):
|
|||||||
# User registration
|
# User registration
|
||||||
def rower_register_view(request):
|
def rower_register_view(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = RegistrationFormUniqueEmail(request.POST)
|
#form = RegistrationFormUniqueEmail(request.POST)
|
||||||
|
form = RegistrationFormSex(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
first_name = form.cleaned_data['first_name']
|
first_name = form.cleaned_data['first_name']
|
||||||
last_name = form.cleaned_data['last_name']
|
last_name = form.cleaned_data['last_name']
|
||||||
email = form.cleaned_data['email']
|
email = form.cleaned_data['email']
|
||||||
password = form.cleaned_data['password1']
|
password = form.cleaned_data['password1']
|
||||||
username = form.cleaned_data['username']
|
username = form.cleaned_data['username']
|
||||||
|
sex = form.cleaned_data['sex']
|
||||||
|
birthdate = form.cleaned_data['birthdate']
|
||||||
|
weightcategory = form.cleaned_data['weightcategory']
|
||||||
theuser = User.objects.create_user(username,password=password)
|
theuser = User.objects.create_user(username,password=password)
|
||||||
theuser.first_name = first_name
|
theuser.first_name = first_name
|
||||||
theuser.last_name = last_name
|
theuser.last_name = last_name
|
||||||
theuser.email = email
|
theuser.email = email
|
||||||
theuser.save()
|
theuser.save()
|
||||||
|
|
||||||
therower = Rower(user=theuser)
|
therower = Rower(user=theuser,sex=sex,birthdate=birthdate,
|
||||||
|
weightcategory=weightcategory)
|
||||||
|
|
||||||
therower.save()
|
therower.save()
|
||||||
|
|
||||||
@@ -843,7 +849,7 @@ Oh, one more thing. The site is currently in beta and is developing fast. Bear w
|
|||||||
"registration_form.html",
|
"registration_form.html",
|
||||||
{'form':form})
|
{'form':form})
|
||||||
else:
|
else:
|
||||||
form = RegistrationFormUniqueEmail()
|
form = RegistrationFormSex()
|
||||||
return render(request,
|
return render(request,
|
||||||
"registration_form.html",
|
"registration_form.html",
|
||||||
{'form':form,})
|
{'form':form,})
|
||||||
@@ -10226,8 +10232,10 @@ def rower_edit_view(request,message=""):
|
|||||||
first_name = ucd['first_name']
|
first_name = ucd['first_name']
|
||||||
last_name = ucd['last_name']
|
last_name = ucd['last_name']
|
||||||
email = ucd['email']
|
email = ucd['email']
|
||||||
|
sex = cd['sex']
|
||||||
defaultlandingpage = cd['defaultlandingpage']
|
defaultlandingpage = cd['defaultlandingpage']
|
||||||
weightcategory = cd['weightcategory']
|
weightcategory = cd['weightcategory']
|
||||||
|
birthdate = cd['birthdate']
|
||||||
showfavoritechartnotes = cd['showfavoritechartnotes']
|
showfavoritechartnotes = cd['showfavoritechartnotes']
|
||||||
getemailnotifications = cd['getemailnotifications']
|
getemailnotifications = cd['getemailnotifications']
|
||||||
defaulttimezone=cd['defaulttimezone']
|
defaulttimezone=cd['defaulttimezone']
|
||||||
@@ -10246,6 +10254,8 @@ def rower_edit_view(request,message=""):
|
|||||||
r.getemailnotifications = getemailnotifications
|
r.getemailnotifications = getemailnotifications
|
||||||
r.defaultlandingpage = defaultlandingpage
|
r.defaultlandingpage = defaultlandingpage
|
||||||
r.showfavoritechartnotes = showfavoritechartnotes
|
r.showfavoritechartnotes = showfavoritechartnotes
|
||||||
|
r.sex = sex
|
||||||
|
r.birthdate = birthdate
|
||||||
r.save()
|
r.save()
|
||||||
form = RowerForm(instance=r)
|
form = RowerForm(instance=r)
|
||||||
powerform = RowerPowerForm(instance=r)
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
|||||||
Reference in New Issue
Block a user