prefix age ranges with a letter, to make them usable as anchors

This commit is contained in:
Frédéric Péters 2011-10-27 15:31:54 +02:00
parent 6de5351ace
commit 5fdf268fc4
1 changed files with 8 additions and 6 deletions

View File

@ -81,6 +81,8 @@ class Deputy(Item):
@property
def agerange(self):
if not self.birthdate:
return '?'
today = datetime.datetime.today()
age = (today.year - self.birthdate.year)
if today.month < self.birthdate.month or \
@ -88,14 +90,14 @@ class Deputy(Item):
today.day < self.birthdate.day):
age -= 1
if age < 30:
return '-30'
return 'm30'
elif age < 40:
return '30-40'
return 'd30-40'
elif age < 50:
return '40-50'
return 'd40-50'
elif age < 60:
return '50-60'
return 'd50-60'
elif age < 70:
return '60-70'
return 'd60-70'
else:
return '+70'
return 'p70'