# HG changeset patch # User Lennard de Rijk # Date 1243667950 -7200 # Node ID 805400745f5751155dbe9624e66d72ef913a2eaa # Parent 85ed68167efbf6331e0f9dc73249c803de20785e Changed University Student expected graduation date to be a dynamic dropdown. The range of choices is dynamically made by taking the current_year-1 to the current_year+20. It does not start at the current year because a Student might need to change it's profile during a Program that runs across multiple years. diff -r 85ed68167efb -r 805400745f57 app/soc/models/student.py --- a/app/soc/models/student.py Sat May 30 01:03:20 2009 +0200 +++ b/app/soc/models/student.py Sat May 30 09:19:10 2009 +0200 @@ -64,8 +64,7 @@ degree.group = ugettext("5. Education") expected_graduation = db.IntegerProperty(required=True, verbose_name=ugettext('Expected Graduation Year')) - expected_graduation.help_text = ugettext("Year in integer format only!") - expected_graduation.example_text = ugettext('Year only, for example "2012"') + expected_graduation.help_text = ugettext("Pick your expected graduation year") expected_graduation.group = ugettext("5. Education") #: Property to gain insight into where students heard about this program diff -r 85ed68167efb -r 805400745f57 app/soc/views/models/student.py --- a/app/soc/views/models/student.py Sat May 30 01:03:20 2009 +0200 +++ b/app/soc/views/models/student.py Sat May 30 09:19:10 2009 +0200 @@ -22,6 +22,8 @@ ] +import time + from django import forms from django.utils.translation import ugettext @@ -99,11 +101,17 @@ new_params['extra_dynaexclude'] = ['agreed_to_tos', 'school'] + current_year = time.gmtime().tm_year + # the current year is not the minimum because a program could span + # more than one year + allowed_years = range(current_year-1, current_year+20) + new_params['create_extra_dynaproperties'] = { - 'expected_graduation': forms.IntegerField(required=True, - max_value=2030, - min_value=2009) - } + 'expected_graduation': forms.TypedChoiceField( + choices=[(x,x) for x in allowed_years], + coerce=lambda val: int(val) + ) + } new_params['create_dynafields'] = [ {'name': 'scope_path',