age calculations
This commit is contained in:
@@ -294,7 +294,10 @@ from datetime import date
|
|||||||
|
|
||||||
def calculate_age(born):
|
def calculate_age(born):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
|
if born:
|
||||||
|
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def my_dict_from_instance(instance,model):
|
def my_dict_from_instance(instance,model):
|
||||||
thedict = {}
|
thedict = {}
|
||||||
|
|||||||
@@ -13579,7 +13579,10 @@ def virtualevent_register_view(request,id=0):
|
|||||||
age = cd['age']
|
age = cd['age']
|
||||||
else:
|
else:
|
||||||
weightcategory = r.weightcategory
|
weightcategory = r.weightcategory
|
||||||
age = calculate_age(r.birthdate)
|
if r.birthdate:
|
||||||
|
age = calculate_age(r.birthdate)
|
||||||
|
else:
|
||||||
|
age = cd['age']
|
||||||
|
|
||||||
record = VirtualRaceResult(
|
record = VirtualRaceResult(
|
||||||
userid=r.id,
|
userid=r.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user