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