[7853] | 1 | ## $Id: interfaces.py 8537 2012-05-28 05:26:18Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """Customized interfaces of the university application package. |
---|
| 19 | """ |
---|
| 20 | |
---|
[8012] | 21 | from zope import schema |
---|
[8051] | 22 | from waeup.kofa.applicants.interfaces import ( |
---|
[8053] | 23 | IApplicantBaseData, |
---|
[8051] | 24 | AppCatCertificateSource, CertificateSource) |
---|
| 25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
[8531] | 26 | from waeup.kofa.interfaces import ( |
---|
| 27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
| 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice |
---|
| 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[8460] | 31 | from waeup.fceokene.interfaces import ( |
---|
[8504] | 32 | LGASource, high_qual, high_grade, exam_types) |
---|
[8460] | 33 | from waeup.fceokene.interfaces import MessageFactory as _ |
---|
| 34 | from waeup.fceokene.payments.interfaces import ICustomOnlinePayment |
---|
[7853] | 35 | |
---|
[8520] | 36 | UG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
| 37 | UG_OMIT_MANAGE_FIELDS = () |
---|
| 38 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted', |
---|
| 39 | 'student_id', 'screening_score', 'screening_venue') |
---|
[8531] | 40 | PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + ( |
---|
| 41 | 'firstname', 'middlename', 'lastname', 'sex', |
---|
[8537] | 42 | 'course1', 'lga', 'jamb_score', 'jamb_subjects') |
---|
[8520] | 43 | |
---|
| 44 | PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
| 45 | PG_OMIT_MANAGE_FIELDS = () |
---|
[8531] | 46 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + ( |
---|
| 47 | 'locked', 'course_admitted', |
---|
[8520] | 48 | 'student_id', 'screening_score', 'screening_venue') |
---|
| 49 | |
---|
[8053] | 50 | class IUGApplicant(IApplicantBaseData): |
---|
[8012] | 51 | """An undergraduate applicant. |
---|
| 52 | |
---|
[8520] | 53 | This interface defines the least common multiple of all fields |
---|
| 54 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 55 | adding them to the UG_OMIT* tuples. |
---|
[8012] | 56 | """ |
---|
| 57 | |
---|
[8071] | 58 | nationality = schema.Choice( |
---|
| 59 | source = nats_vocab, |
---|
| 60 | title = _(u'Nationality'), |
---|
| 61 | required = False, |
---|
| 62 | ) |
---|
| 63 | lga = schema.Choice( |
---|
[8504] | 64 | source = LGASource(), |
---|
[8071] | 65 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 66 | required = False, |
---|
| 67 | ) |
---|
[8531] | 68 | perm_address = schema.Text( |
---|
| 69 | title = _(u'Permanent Address'), |
---|
| 70 | required = False, |
---|
| 71 | ) |
---|
| 72 | course1 = schema.Choice( |
---|
| 73 | title = _(u'1st Choice Course of Study'), |
---|
| 74 | source = AppCatCertificateSource(), |
---|
| 75 | required = True, |
---|
| 76 | ) |
---|
| 77 | course2 = schema.Choice( |
---|
| 78 | title = _(u'2nd Choice Course of Study'), |
---|
| 79 | source = AppCatCertificateSource(), |
---|
| 80 | required = False, |
---|
| 81 | ) |
---|
[8537] | 82 | jamb_subjects = schema.Text( |
---|
| 83 | title = _(u'Subjects and Scores'), |
---|
[8531] | 84 | required = False, |
---|
| 85 | ) |
---|
[8537] | 86 | jamb_score = schema.Int( |
---|
| 87 | title = _(u'Total Score'), |
---|
| 88 | required = False, |
---|
| 89 | ) |
---|
[8531] | 90 | notice = schema.Text( |
---|
| 91 | title = _(u'Notice'), |
---|
| 92 | required = False, |
---|
| 93 | ) |
---|
| 94 | screening_venue = schema.TextLine( |
---|
| 95 | title = _(u'Screening Venue'), |
---|
| 96 | required = False, |
---|
| 97 | ) |
---|
| 98 | screening_score = schema.Int( |
---|
| 99 | title = _(u'Screening Score'), |
---|
| 100 | required = False, |
---|
| 101 | ) |
---|
| 102 | student_id = schema.TextLine( |
---|
| 103 | title = _(u'Student Id'), |
---|
| 104 | required = False, |
---|
| 105 | readonly = False, |
---|
| 106 | ) |
---|
| 107 | course_admitted = schema.Choice( |
---|
| 108 | title = _(u'Admitted Course of Study'), |
---|
| 109 | source = CertificateSource(), |
---|
| 110 | required = False, |
---|
| 111 | ) |
---|
| 112 | locked = schema.Bool( |
---|
| 113 | title = _(u'Form locked'), |
---|
| 114 | default = False, |
---|
| 115 | ) |
---|
| 116 | |
---|
[8053] | 117 | class IPGApplicant(IApplicantBaseData): |
---|
[7853] | 118 | """A postgraduate applicant. |
---|
| 119 | |
---|
[8520] | 120 | This interface defines the least common multiple of all fields |
---|
| 121 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 122 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 123 | """ |
---|
| 124 | |
---|
[8071] | 125 | nationality = schema.Choice( |
---|
| 126 | source = nats_vocab, |
---|
| 127 | title = _(u'Nationality'), |
---|
| 128 | required = False, |
---|
| 129 | ) |
---|
| 130 | lga = schema.Choice( |
---|
[8504] | 131 | source = LGASource(), |
---|
[8071] | 132 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 133 | required = False, |
---|
| 134 | ) |
---|
[8051] | 135 | perm_address = schema.Text( |
---|
| 136 | title = _(u'Permanent Address'), |
---|
| 137 | required = False, |
---|
| 138 | ) |
---|
| 139 | course1 = schema.Choice( |
---|
| 140 | title = _(u'1st Choice Course of Study'), |
---|
| 141 | source = AppCatCertificateSource(), |
---|
| 142 | required = True, |
---|
| 143 | ) |
---|
| 144 | course2 = schema.Choice( |
---|
| 145 | title = _(u'2nd Choice Course of Study'), |
---|
| 146 | source = AppCatCertificateSource(), |
---|
| 147 | required = False, |
---|
| 148 | ) |
---|
| 149 | hq_type = schema.Choice( |
---|
| 150 | title = _(u'Qualification Obtained'), |
---|
| 151 | required = False, |
---|
| 152 | readonly = False, |
---|
| 153 | vocabulary = high_qual, |
---|
| 154 | ) |
---|
| 155 | hq_matric_no = schema.TextLine( |
---|
| 156 | title = _(u'Former Matric Number'), |
---|
| 157 | required = False, |
---|
| 158 | readonly = False, |
---|
| 159 | ) |
---|
| 160 | hq_degree = schema.Choice( |
---|
| 161 | title = _(u'Class of Degree'), |
---|
| 162 | required = False, |
---|
| 163 | readonly = False, |
---|
| 164 | vocabulary = high_grade, |
---|
| 165 | ) |
---|
| 166 | hq_school = schema.TextLine( |
---|
| 167 | title = _(u'Institution Attended'), |
---|
| 168 | required = False, |
---|
| 169 | readonly = False, |
---|
| 170 | ) |
---|
| 171 | hq_session = schema.TextLine( |
---|
| 172 | title = _(u'Years Attended'), |
---|
| 173 | required = False, |
---|
| 174 | readonly = False, |
---|
| 175 | ) |
---|
| 176 | hq_disc = schema.TextLine( |
---|
| 177 | title = _(u'Discipline'), |
---|
| 178 | required = False, |
---|
| 179 | readonly = False, |
---|
| 180 | ) |
---|
| 181 | pp_school = schema.Choice( |
---|
| 182 | title = _(u'Qualification Obtained'), |
---|
| 183 | required = False, |
---|
| 184 | readonly = False, |
---|
| 185 | vocabulary = exam_types, |
---|
| 186 | ) |
---|
[8101] | 187 | #presently = schema.Bool( |
---|
| 188 | # title = _(u'Attending'), |
---|
| 189 | # required = False, |
---|
| 190 | # readonly = False, |
---|
| 191 | # ) |
---|
| 192 | presently_inst = schema.TextLine( |
---|
| 193 | title = _(u'If yes, name of institution'), |
---|
| 194 | required = False, |
---|
| 195 | readonly = False, |
---|
| 196 | ) |
---|
| 197 | nysc_year = schema.Int( |
---|
| 198 | title = _(u'Nysc Year'), |
---|
| 199 | required = False, |
---|
| 200 | readonly = False, |
---|
| 201 | ) |
---|
| 202 | nysc_lga = schema.Choice( |
---|
[8504] | 203 | source = LGASource(), |
---|
[8101] | 204 | title = _(u'Nysc Location'), |
---|
| 205 | required = False, |
---|
| 206 | ) |
---|
[8012] | 207 | employer = schema.TextLine( |
---|
| 208 | title = _(u'Employer'), |
---|
| 209 | required = False, |
---|
| 210 | readonly = False, |
---|
| 211 | ) |
---|
[8051] | 212 | emp_position = schema.TextLine( |
---|
| 213 | title = _(u'Employer Position'), |
---|
| 214 | required = False, |
---|
| 215 | readonly = False, |
---|
| 216 | ) |
---|
[8184] | 217 | emp_start = FormattedDate( |
---|
[8051] | 218 | title = _(u'Start Date'), |
---|
| 219 | required = False, |
---|
| 220 | readonly = False, |
---|
[8378] | 221 | show_year = True, |
---|
[8051] | 222 | ) |
---|
[8184] | 223 | emp_end = FormattedDate( |
---|
[8051] | 224 | title = _(u'End Date'), |
---|
| 225 | required = False, |
---|
| 226 | readonly = False, |
---|
[8378] | 227 | show_year = True, |
---|
[8051] | 228 | ) |
---|
| 229 | emp_reason = schema.TextLine( |
---|
| 230 | title = _(u'Reason for Leaving'), |
---|
| 231 | required = False, |
---|
| 232 | readonly = False, |
---|
| 233 | ) |
---|
| 234 | employer2 = schema.TextLine( |
---|
| 235 | title = _(u'2nd Employer'), |
---|
| 236 | required = False, |
---|
| 237 | readonly = False, |
---|
| 238 | ) |
---|
| 239 | emp2_position = schema.TextLine( |
---|
| 240 | title = _(u'2nd Employer Position'), |
---|
| 241 | required = False, |
---|
| 242 | readonly = False, |
---|
| 243 | ) |
---|
[8184] | 244 | emp2_start = FormattedDate( |
---|
[8051] | 245 | title = _(u'Start Date'), |
---|
| 246 | required = False, |
---|
| 247 | readonly = False, |
---|
[8378] | 248 | show_year = True, |
---|
[8051] | 249 | ) |
---|
[8184] | 250 | emp2_end = FormattedDate( |
---|
[8051] | 251 | title = _(u'End Date'), |
---|
| 252 | required = False, |
---|
| 253 | readonly = False, |
---|
[8378] | 254 | show_year = True, |
---|
[8051] | 255 | ) |
---|
| 256 | emp2_reason = schema.TextLine( |
---|
| 257 | title = _(u'Reason for Leaving'), |
---|
| 258 | required = False, |
---|
| 259 | readonly = False, |
---|
| 260 | ) |
---|
| 261 | notice = schema.Text( |
---|
| 262 | title = _(u'Notice'), |
---|
| 263 | required = False, |
---|
| 264 | readonly = False, |
---|
| 265 | ) |
---|
| 266 | screening_venue = schema.TextLine( |
---|
| 267 | title = _(u'Screening Venue'), |
---|
| 268 | required = False, |
---|
| 269 | readonly = False, |
---|
| 270 | ) |
---|
| 271 | screening_score = schema.Int( |
---|
| 272 | title = _(u'Screening Score'), |
---|
| 273 | required = False, |
---|
| 274 | readonly = False, |
---|
| 275 | ) |
---|
[8531] | 276 | student_id = schema.TextLine( |
---|
| 277 | title = _(u'Student Id'), |
---|
| 278 | required = False, |
---|
| 279 | readonly = False, |
---|
| 280 | ) |
---|
[8051] | 281 | course_admitted = schema.Choice( |
---|
| 282 | title = _(u'Admitted Course of Study'), |
---|
| 283 | source = CertificateSource(), |
---|
| 284 | required = False, |
---|
| 285 | readonly = False, |
---|
| 286 | ) |
---|
[8531] | 287 | locked = schema.Bool( |
---|
| 288 | title = _(u'Form locked'), |
---|
| 289 | default = False, |
---|
| 290 | ) |
---|
[8012] | 291 | |
---|
[8196] | 292 | class ICustomApplicant(IUGApplicant,IPGApplicant): |
---|
[8012] | 293 | """An interface for both types of applicants. |
---|
| 294 | |
---|
| 295 | """ |
---|
| 296 | |
---|
[8053] | 297 | def loggerInfo(ob_class, comment): |
---|
| 298 | """Adds an INFO message to the log file |
---|
| 299 | """ |
---|
| 300 | |
---|
| 301 | def createStudent(): |
---|
| 302 | """Create a student object from applicatnt data |
---|
| 303 | and copy applicant object. |
---|
| 304 | """ |
---|
| 305 | |
---|
[8017] | 306 | class IUGApplicantEdit(IUGApplicant): |
---|
[8012] | 307 | """An undergraduate applicant interface for editing. |
---|
| 308 | |
---|
| 309 | Here we can repeat the fields from base data and set the |
---|
| 310 | `required` and `readonly` attributes to True to further restrict |
---|
| 311 | the data access. Or we can allow only certain certificates to be |
---|
| 312 | selected by choosing the appropriate source. |
---|
| 313 | |
---|
| 314 | We cannot omit fields here. This has to be done in the |
---|
| 315 | respective form page. |
---|
| 316 | """ |
---|
| 317 | |
---|
[8017] | 318 | class IPGApplicantEdit(IPGApplicant): |
---|
[7866] | 319 | """A postgraduate applicant interface for editing. |
---|
| 320 | |
---|
| 321 | Here we can repeat the fields from base data and set the |
---|
| 322 | `required` and `readonly` attributes to True to further restrict |
---|
| 323 | the data access. Or we can allow only certain certificates to be |
---|
| 324 | selected by choosing the appropriate source. |
---|
| 325 | |
---|
| 326 | We cannot omit fields here. This has to be done in the |
---|
| 327 | respective form page. |
---|
[8017] | 328 | """ |
---|
[8454] | 329 | |
---|
[8247] | 330 | class ICustomApplicantOnlinePayment(ICustomOnlinePayment): |
---|
| 331 | """An applicant payment via payment gateways. |
---|
| 332 | |
---|
| 333 | """ |
---|
[8531] | 334 | |
---|
| 335 | class IPUTMEApplicantEdit(IUGApplicant): |
---|
| 336 | """An undergraduate applicant interface for editing. |
---|
| 337 | |
---|
| 338 | Here we can repeat the fields from base data and set the |
---|
| 339 | `required` and `readonly` attributes to True to further restrict |
---|
| 340 | the data access. Or we can allow only certain certificates to be |
---|
| 341 | selected by choosing the appropriate source. |
---|
| 342 | |
---|
| 343 | We cannot omit fields here. This has to be done in the |
---|
| 344 | respective form page. |
---|
| 345 | """ |
---|
| 346 | email = schema.ASCIILine( |
---|
| 347 | title = _(u'Email Address'), |
---|
| 348 | required = True, |
---|
| 349 | constraint=validate_email, |
---|
| 350 | ) |
---|
| 351 | |
---|
| 352 | IPUTMEApplicantEdit[ |
---|
| 353 | 'email'].order = IUGApplicant['email'].order |
---|