Moved the Student cleaner to the create form such that it is always used.
Also enforced that the user picks a School type in the cleaner for the time being.
--- a/app/soc/logic/cleaning.py Tue Sep 15 22:23:06 2009 +0200
+++ b/app/soc/logic/cleaning.py Tue Sep 15 22:38:01 2009 +0200
@@ -707,7 +707,7 @@
# nothing to check, field validator will find these errors
return cleaned_data
- # get the current program entity or bail out 404
+ # get the current program entity
entity = program_logic.getFromKeyName(program_key_name)
if not entity:
@@ -718,6 +718,10 @@
major = cleaned_data.get(major_field)
degree = cleaned_data.get(degree_field)
+ # TODO: when school_type is required this can be removed
+ if not school_type:
+ raise forms.ValidationError("School type cannot be left blank.")
+
# if school_type is University, check for major
if school_type == 'University' and not major:
raise forms.ValidationError("Major cannot be left blank.")
--- a/app/soc/views/models/student.py Tue Sep 15 22:23:06 2009 +0200
+++ b/app/soc/views/models/student.py Tue Sep 15 22:38:01 2009 +0200
@@ -112,11 +112,16 @@
# more than one year
allowed_years = range(current_year-1, current_year+20)
+ view_logic = params['logic'] if params else new_params['logic']
+
new_params['create_extra_dynaproperties'] = {
'expected_graduation': forms.TypedChoiceField(
choices=[(x,x) for x in allowed_years],
coerce=lambda val: int(val)
),
+ 'clean': cleaning.validate_student(
+ 'birth_date', 'school_type', 'major', 'degree', 'grade',
+ 'scope_path', view_logic.getScopeLogic().logic),
}
new_params['create_dynafields'] = [
@@ -151,9 +156,6 @@
'link_id': forms.CharField(widget=forms.HiddenInput,
required=True),
'clean_link_id': cleaning.clean_user_is_current('link_id'),
- 'clean': cleaning.validate_student(
- 'birth_date', 'school_type', 'major', 'degree', 'grade',
- 'scope_path', self._logic.getScopeLogic().logic),
}
user_create_form = dynaform.extendDynaForm(