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