in Allura/allura/lib/widgets/forms.py [0:0]
def display(self, **kw):
user = kw.get('user')
self._fields = self.fields
birthdate_field = [x for x in self._fields if x.name == 'birthdate']
sex_field = [x for x in self._fields if x.name == 'sex'][0]
country_field = [x for x in self._fields if x.name == 'country'][0]
city_field = [x for x in self._fields if x.name == 'city'][0]
timezone_field = [x for x in self._fields if x.name == 'timezone'][0]
for opt in sex_field.options:
if opt.label == user.sex:
opt.selected = True
else:
opt.selected = False
if birthdate_field:
if user.get_pref('birthdate'):
birthdate_field[0].attrs['value'] = user.get_pref('birthdate').strftime('%d/%m/%Y')
else:
birthdate_field[0].attrs['value'] = ''
for opt in country_field.options:
if opt.label == user.localization.country:
opt.selected = True
elif opt.py_value == " " and user.localization.country is None:
opt.selected = True
else:
opt.selected = False
if user.localization.city:
city_field.attrs['value'] = user.localization.city
else:
city_field.attrs['value'] = ''
for opt in timezone_field.options:
if opt.label == user.timezone:
opt.selected = True
elif opt.py_value == " " and user.timezone is None:
opt.selected = True
else:
opt.selected = False
return super(ForgeForm, self).display(**kw)