function to get age range of deputy
This commit is contained in:
parent
df72d74099
commit
16ddfccc2d
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from five import grok
|
||||
from zope import schema
|
||||
from zope.interface import implements
|
||||
|
@ -61,3 +63,23 @@ class Deputy(Item):
|
|||
def setTitle(self, value):
|
||||
pass
|
||||
|
||||
@property
|
||||
def agerange(self):
|
||||
today = datetime.datetime.today()
|
||||
age = (today.year - self.birthdate.year)
|
||||
if today.month < self.birthdate.month or \
|
||||
(today.month == self.birthdate.month and
|
||||
today.day < self.birthdate.day):
|
||||
age -= 1
|
||||
if age < 30:
|
||||
return '-30'
|
||||
elif age < 40:
|
||||
return '30-40'
|
||||
elif age < 50:
|
||||
return '40-50'
|
||||
elif age < 60:
|
||||
return '50-60'
|
||||
elif age < 70:
|
||||
return '60-70'
|
||||
else:
|
||||
return '+70'
|
||||
|
|
Reference in New Issue