[7853] | 1 | ## $Id: interfaces.py 10640 2013-09-23 05:29:14Z 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) |
---|
[10640] | 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
[8531] | 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[8933] | 31 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 32 | LGASource, high_qual, high_grade, exam_types, |
---|
[10132] | 33 | OMIT_DISPLAY_FIELDS, |
---|
[8933] | 34 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
| 35 | INigeriaApplicantOnlinePayment, |
---|
[8979] | 36 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
| 37 | INigeriaApplicantUpdateByRegNo, |
---|
| 38 | IPUTMEApplicantEdit, |
---|
[8933] | 39 | ) |
---|
[9347] | 40 | from waeup.kwarapoly.interfaces import MessageFactory as _ |
---|
| 41 | from waeup.kwarapoly.payments.interfaces import ICustomOnlinePayment |
---|
[7853] | 42 | |
---|
[10132] | 43 | ND_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
| 44 | 'hq_type', |
---|
| 45 | 'hq_matric_no', |
---|
| 46 | 'hq_degree', |
---|
| 47 | 'hq_school', |
---|
| 48 | 'hq_session', |
---|
| 49 | 'hq_disc', |
---|
| 50 | 'hq_type') |
---|
| 51 | ND_OMIT_PDF_FIELDS = ND_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
| 52 | ND_OMIT_MANAGE_FIELDS = () |
---|
| 53 | ND_OMIT_EDIT_FIELDS = ND_OMIT_MANAGE_FIELDS + ND_OMIT_DISPLAY_FIELDS + ( |
---|
| 54 | 'student_id', 'notice', |
---|
| 55 | 'screening_score', |
---|
| 56 | 'screening_venue', |
---|
| 57 | 'screening_date', |
---|
| 58 | 'jamb_subjects', |
---|
| 59 | 'jamb_score', |
---|
| 60 | 'aggregate') |
---|
| 61 | |
---|
| 62 | class ICustomUGApplicant(IApplicantBaseData): |
---|
[8012] | 63 | """An undergraduate applicant. |
---|
| 64 | |
---|
[8520] | 65 | This interface defines the least common multiple of all fields |
---|
| 66 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 67 | adding them to the UG_OMIT* tuples. |
---|
[8012] | 68 | """ |
---|
[10594] | 69 | sex = schema.Choice( |
---|
| 70 | title = _(u'Sex'), |
---|
| 71 | source = GenderSource(), |
---|
| 72 | required = False, |
---|
| 73 | ) |
---|
[10132] | 74 | nationality = schema.Choice( |
---|
| 75 | source = nats_vocab, |
---|
| 76 | title = _(u'Nationality'), |
---|
[10594] | 77 | required = False, |
---|
[10132] | 78 | ) |
---|
| 79 | lga = schema.Choice( |
---|
| 80 | source = LGASource(), |
---|
| 81 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 82 | required = False, |
---|
| 83 | ) |
---|
| 84 | #perm_address = schema.Text( |
---|
| 85 | # title = _(u'Permanent Address'), |
---|
| 86 | # required = False, |
---|
| 87 | # ) |
---|
| 88 | next_kin_address = schema.Text( |
---|
| 89 | title = _(u'Next of Kin Address'), |
---|
| 90 | required = False, |
---|
| 91 | ) |
---|
[10167] | 92 | jamb_reg_number = schema.TextLine( |
---|
| 93 | title = _(u'JAMB Registration Number'), |
---|
| 94 | required = False, |
---|
| 95 | ) |
---|
[10132] | 96 | course1 = schema.Choice( |
---|
| 97 | title = _(u'1st Choice Course of Study'), |
---|
| 98 | source = AppCatCertificateSource(), |
---|
[10594] | 99 | required = False, |
---|
[10132] | 100 | ) |
---|
| 101 | course2 = schema.Choice( |
---|
| 102 | title = _(u'2nd Choice Course of Study'), |
---|
| 103 | source = AppCatCertificateSource(), |
---|
| 104 | required = False, |
---|
| 105 | ) |
---|
| 106 | olevel_type = schema.Choice( |
---|
| 107 | title = _(u'Qualification Obtained'), |
---|
| 108 | required = False, |
---|
| 109 | readonly = False, |
---|
| 110 | vocabulary = exam_types, |
---|
| 111 | ) |
---|
| 112 | olevel_school = schema.TextLine( |
---|
| 113 | title = _(u'Institution Attended'), |
---|
| 114 | required = False, |
---|
| 115 | readonly = False, |
---|
| 116 | ) |
---|
| 117 | olevel_exam_number = schema.TextLine( |
---|
| 118 | title = _(u'Exam Number'), |
---|
| 119 | required = False, |
---|
| 120 | readonly = False, |
---|
| 121 | ) |
---|
| 122 | olevel_exam_date = FormattedDate( |
---|
| 123 | title = _(u'Exam Date'), |
---|
| 124 | required = False, |
---|
| 125 | readonly = False, |
---|
| 126 | show_year = True, |
---|
| 127 | ) |
---|
| 128 | olevel_results = schema.List( |
---|
| 129 | title = _(u'Exam Results'), |
---|
| 130 | value_type = ResultEntryField(), |
---|
| 131 | required = False, |
---|
| 132 | readonly = False, |
---|
| 133 | default = [], |
---|
| 134 | ) |
---|
[10619] | 135 | olevel_type2 = schema.Choice( |
---|
| 136 | title = _(u'2nd Qualification Obtained'), |
---|
| 137 | required = False, |
---|
| 138 | readonly = False, |
---|
| 139 | vocabulary = exam_types, |
---|
| 140 | ) |
---|
| 141 | olevel_school2 = schema.TextLine( |
---|
| 142 | title = _(u'2nd Institution Attended'), |
---|
| 143 | required = False, |
---|
| 144 | readonly = False, |
---|
| 145 | ) |
---|
| 146 | olevel_exam_number2 = schema.TextLine( |
---|
| 147 | title = _(u'2nd Exam Number'), |
---|
| 148 | required = False, |
---|
| 149 | readonly = False, |
---|
| 150 | ) |
---|
| 151 | olevel_exam_date2 = FormattedDate( |
---|
| 152 | title = _(u'2nd Exam Date'), |
---|
| 153 | required = False, |
---|
| 154 | readonly = False, |
---|
| 155 | show_year = True, |
---|
| 156 | ) |
---|
| 157 | olevel_results2 = schema.List( |
---|
| 158 | title = _(u'2nd Exam Results'), |
---|
| 159 | value_type = ResultEntryField(), |
---|
| 160 | required = False, |
---|
| 161 | readonly = False, |
---|
| 162 | default = [], |
---|
| 163 | ) |
---|
[10132] | 164 | hq_type = schema.Choice( |
---|
| 165 | title = _(u'Qualification Obtained'), |
---|
| 166 | required = False, |
---|
| 167 | readonly = False, |
---|
| 168 | vocabulary = high_qual, |
---|
| 169 | ) |
---|
| 170 | hq_matric_no = schema.TextLine( |
---|
| 171 | title = _(u'Former Matric Number'), |
---|
| 172 | required = False, |
---|
| 173 | readonly = False, |
---|
| 174 | ) |
---|
| 175 | hq_degree = schema.Choice( |
---|
| 176 | title = _(u'Class of Degree'), |
---|
| 177 | required = False, |
---|
| 178 | readonly = False, |
---|
| 179 | vocabulary = high_grade, |
---|
| 180 | ) |
---|
| 181 | hq_school = schema.TextLine( |
---|
| 182 | title = _(u'Institution Attended'), |
---|
| 183 | required = False, |
---|
| 184 | readonly = False, |
---|
| 185 | ) |
---|
| 186 | hq_session = schema.TextLine( |
---|
| 187 | title = _(u'Years Attended'), |
---|
| 188 | required = False, |
---|
| 189 | readonly = False, |
---|
| 190 | ) |
---|
| 191 | hq_disc = schema.TextLine( |
---|
| 192 | title = _(u'Discipline'), |
---|
| 193 | required = False, |
---|
| 194 | readonly = False, |
---|
| 195 | ) |
---|
| 196 | jamb_subjects = schema.Text( |
---|
| 197 | title = _(u'Subjects and Scores'), |
---|
[10590] | 198 | description = _(u'(one subject with score per line)'), |
---|
[10132] | 199 | required = False, |
---|
| 200 | ) |
---|
| 201 | jamb_score = schema.Int( |
---|
| 202 | title = _(u'Total JAMB Score'), |
---|
| 203 | required = False, |
---|
| 204 | ) |
---|
| 205 | notice = schema.Text( |
---|
| 206 | title = _(u'Notice'), |
---|
| 207 | required = False, |
---|
| 208 | ) |
---|
| 209 | screening_venue = schema.TextLine( |
---|
| 210 | title = _(u'Screening Venue'), |
---|
| 211 | required = False, |
---|
| 212 | ) |
---|
| 213 | screening_date = schema.TextLine( |
---|
| 214 | title = _(u'Screening Date'), |
---|
| 215 | required = False, |
---|
| 216 | ) |
---|
| 217 | screening_score = schema.Int( |
---|
| 218 | title = _(u'Screening Score (%)'), |
---|
| 219 | required = False, |
---|
| 220 | ) |
---|
| 221 | aggregate = schema.Int( |
---|
| 222 | title = _(u'Aggregate Score (%)'), |
---|
| 223 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 224 | required = False, |
---|
| 225 | ) |
---|
| 226 | result_uploaded = schema.Bool( |
---|
| 227 | title = _(u'Result uploaded'), |
---|
| 228 | default = False, |
---|
[10594] | 229 | required = False, |
---|
[10132] | 230 | ) |
---|
| 231 | student_id = schema.TextLine( |
---|
| 232 | title = _(u'Student Id'), |
---|
| 233 | required = False, |
---|
| 234 | readonly = False, |
---|
| 235 | ) |
---|
| 236 | course_admitted = schema.Choice( |
---|
| 237 | title = _(u'Admitted Course of Study'), |
---|
| 238 | source = CertificateSource(), |
---|
| 239 | required = False, |
---|
| 240 | ) |
---|
| 241 | locked = schema.Bool( |
---|
| 242 | title = _(u'Form locked'), |
---|
| 243 | default = False, |
---|
[10594] | 244 | required = False, |
---|
[10132] | 245 | ) |
---|
| 246 | |
---|
[10594] | 247 | ICustomUGApplicant[ |
---|
| 248 | 'sex'].order = IApplicantBaseData['sex'].order |
---|
| 249 | |
---|
[8933] | 250 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
[7853] | 251 | """A postgraduate applicant. |
---|
| 252 | |
---|
[8520] | 253 | This interface defines the least common multiple of all fields |
---|
| 254 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 255 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 256 | """ |
---|
| 257 | |
---|
[8933] | 258 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
[8012] | 259 | """An interface for both types of applicants. |
---|
| 260 | |
---|
[8933] | 261 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 262 | by ICustomPGApplicant field settings. If a field is defined |
---|
[8729] | 263 | in both interfaces zope.schema validates only against the |
---|
[8933] | 264 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 265 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
[8012] | 266 | """ |
---|
| 267 | |
---|
[8745] | 268 | def writeLogMessage(view, comment): |
---|
[8053] | 269 | """Adds an INFO message to the log file |
---|
| 270 | """ |
---|
| 271 | |
---|
| 272 | def createStudent(): |
---|
| 273 | """Create a student object from applicatnt data |
---|
| 274 | and copy applicant object. |
---|
| 275 | """ |
---|
| 276 | |
---|
[10132] | 277 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[8729] | 278 | """An undergraduate applicant interface for edit forms. |
---|
[8012] | 279 | |
---|
| 280 | Here we can repeat the fields from base data and set the |
---|
| 281 | `required` and `readonly` attributes to True to further restrict |
---|
| 282 | the data access. Or we can allow only certain certificates to be |
---|
| 283 | selected by choosing the appropriate source. |
---|
| 284 | |
---|
| 285 | We cannot omit fields here. This has to be done in the |
---|
| 286 | respective form page. |
---|
| 287 | """ |
---|
[10640] | 288 | email = schema.ASCIILine( |
---|
| 289 | title = _(u'Email Address'), |
---|
| 290 | required = True, |
---|
| 291 | constraint=validate_email, |
---|
| 292 | ) |
---|
| 293 | phone = PhoneNumber( |
---|
| 294 | title = _(u'Phone'), |
---|
| 295 | description = u'', |
---|
| 296 | required = True, |
---|
| 297 | ) |
---|
[10594] | 298 | sex = schema.Choice( |
---|
| 299 | title = _(u'Sex'), |
---|
| 300 | source = GenderSource(), |
---|
| 301 | required = True, |
---|
| 302 | ) |
---|
| 303 | course1 = schema.Choice( |
---|
| 304 | title = _(u'1st Choice Course of Study'), |
---|
| 305 | source = AppCatCertificateSource(), |
---|
| 306 | required = True, |
---|
| 307 | ) |
---|
[10640] | 308 | olevel_type = schema.Choice( |
---|
| 309 | title = _(u'Qualification Obtained'), |
---|
| 310 | required = True, |
---|
| 311 | readonly = False, |
---|
| 312 | vocabulary = exam_types, |
---|
| 313 | ) |
---|
| 314 | jamb_subjects = schema.Text( |
---|
| 315 | title = _(u'Subjects and Scores'), |
---|
| 316 | description = _(u'(one subject with score per line)'), |
---|
| 317 | required = True, |
---|
| 318 | ) |
---|
[10594] | 319 | |
---|
| 320 | ICustomUGApplicantEdit[ |
---|
[10640] | 321 | 'email'].order = ICustomUGApplicant['email'].order |
---|
| 322 | ICustomUGApplicantEdit[ |
---|
| 323 | 'phone'].order = ICustomUGApplicant['phone'].order |
---|
| 324 | ICustomUGApplicantEdit[ |
---|
[10594] | 325 | 'course1'].order = ICustomUGApplicant['course1'].order |
---|
| 326 | ICustomUGApplicantEdit[ |
---|
| 327 | 'sex'].order = ICustomUGApplicant['sex'].order |
---|
[10640] | 328 | ICustomUGApplicantEdit[ |
---|
| 329 | 'olevel_type'].order = ICustomUGApplicant['olevel_type'].order |
---|
| 330 | ICustomUGApplicantEdit[ |
---|
| 331 | 'jamb_subjects'].order = ICustomUGApplicant['jamb_subjects'].order |
---|
[10594] | 332 | |
---|
[8979] | 333 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
[7866] | 334 | """A postgraduate applicant interface for editing. |
---|
| 335 | |
---|
| 336 | Here we can repeat the fields from base data and set the |
---|
| 337 | `required` and `readonly` attributes to True to further restrict |
---|
| 338 | the data access. Or we can allow only certain certificates to be |
---|
| 339 | selected by choosing the appropriate source. |
---|
| 340 | |
---|
| 341 | We cannot omit fields here. This has to be done in the |
---|
| 342 | respective form page. |
---|
[8017] | 343 | """ |
---|
[8454] | 344 | |
---|
[8933] | 345 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
[8247] | 346 | """An applicant payment via payment gateways. |
---|
| 347 | |
---|
| 348 | """ |
---|
[8531] | 349 | |
---|