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