[7853] | 1 | ## $Id: interfaces.py 10217 2013-05-24 05:18:59Z 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 |
---|
[10217] | 22 | from zope.interface import Attribute, invariant, Invalid |
---|
[8051] | 23 | from waeup.kofa.applicants.interfaces import ( |
---|
[8053] | 24 | IApplicantBaseData, |
---|
[8051] | 25 | AppCatCertificateSource, CertificateSource) |
---|
[10088] | 26 | from waeup.kofa.students.vocabularies import nats_vocab |
---|
[8932] | 27 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
[10088] | 28 | LGASource, |
---|
[10204] | 29 | high_qual, high_grade, exam_types, |
---|
[10088] | 30 | INigeriaUGApplicant, |
---|
[8932] | 31 | INigeriaApplicantOnlinePayment, |
---|
[8981] | 32 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
| 33 | INigeriaApplicantUpdateByRegNo, |
---|
| 34 | IPUTMEApplicantEdit, |
---|
[10088] | 35 | OMIT_DISPLAY_FIELDS, |
---|
| 36 | UG_OMIT_DISPLAY_FIELDS, |
---|
| 37 | UG_OMIT_PDF_FIELDS, |
---|
| 38 | UG_OMIT_MANAGE_FIELDS, |
---|
| 39 | UG_OMIT_EDIT_FIELDS, |
---|
[10204] | 40 | PUTME_OMIT_EDIT_FIELDS, |
---|
| 41 | PUTME_OMIT_DISPLAY_FIELDS, |
---|
| 42 | PUTME_OMIT_PDF_FIELDS, |
---|
| 43 | PUTME_OMIT_MANAGE_FIELDS, |
---|
[10217] | 44 | PUTME_OMIT_FIELDS, |
---|
| 45 | #PUTME_OMIT_EDIT_FIELDS, |
---|
[8932] | 46 | ) |
---|
[10088] | 47 | |
---|
[10217] | 48 | PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + ( |
---|
| 49 | 'firstname', 'middlename', 'lastname', 'sex', |
---|
| 50 | 'lga') |
---|
| 51 | |
---|
[10088] | 52 | PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ('course2',) |
---|
| 53 | PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
| 54 | PG_OMIT_MANAGE_FIELDS = ('course2',) |
---|
| 55 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + ( |
---|
| 56 | 'student_id', 'notice', |
---|
| 57 | 'screening_score', 'screening_venue', |
---|
| 58 | 'screening_date',) |
---|
| 59 | |
---|
[8619] | 60 | from waeup.futminna.interfaces import MessageFactory as _ |
---|
[7853] | 61 | |
---|
[10204] | 62 | class ICustomUGApplicant(IApplicantBaseData): |
---|
[8012] | 63 | """An undergraduate applicant. |
---|
| 64 | |
---|
[8519] | 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 | """ |
---|
| 69 | |
---|
[10204] | 70 | nationality = schema.Choice( |
---|
| 71 | source = nats_vocab, |
---|
| 72 | title = _(u'Nationality'), |
---|
| 73 | required = True, |
---|
| 74 | ) |
---|
| 75 | lga = schema.Choice( |
---|
| 76 | source = LGASource(), |
---|
| 77 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 78 | required = False, |
---|
| 79 | ) |
---|
| 80 | perm_address = schema.Text( |
---|
| 81 | title = _(u'Permanent Address'), |
---|
| 82 | required = False, |
---|
| 83 | ) |
---|
| 84 | course1 = schema.Choice( |
---|
| 85 | title = _(u'1st Choice Course of Study'), |
---|
| 86 | source = AppCatCertificateSource(), |
---|
| 87 | required = True, |
---|
| 88 | ) |
---|
| 89 | course2 = schema.Choice( |
---|
| 90 | title = _(u'2nd Choice Course of Study'), |
---|
| 91 | source = AppCatCertificateSource(), |
---|
[10217] | 92 | required = False, |
---|
[10204] | 93 | ) |
---|
| 94 | hq_type = schema.Choice( |
---|
| 95 | title = _(u'Qualification Obtained'), |
---|
| 96 | required = False, |
---|
| 97 | readonly = False, |
---|
| 98 | vocabulary = high_qual, |
---|
| 99 | ) |
---|
| 100 | hq_matric_no = schema.TextLine( |
---|
| 101 | title = _(u'Former Matric Number'), |
---|
| 102 | required = False, |
---|
| 103 | readonly = False, |
---|
| 104 | ) |
---|
| 105 | hq_degree = schema.Choice( |
---|
| 106 | title = _(u'Class of Degree'), |
---|
| 107 | required = False, |
---|
| 108 | readonly = False, |
---|
| 109 | vocabulary = high_grade, |
---|
| 110 | ) |
---|
| 111 | hq_school = schema.TextLine( |
---|
| 112 | title = _(u'Institution Attended'), |
---|
| 113 | required = False, |
---|
| 114 | readonly = False, |
---|
| 115 | ) |
---|
| 116 | hq_session = schema.TextLine( |
---|
| 117 | title = _(u'Years Attended'), |
---|
| 118 | required = False, |
---|
| 119 | readonly = False, |
---|
| 120 | ) |
---|
| 121 | hq_disc = schema.TextLine( |
---|
| 122 | title = _(u'Discipline'), |
---|
| 123 | required = False, |
---|
| 124 | readonly = False, |
---|
| 125 | ) |
---|
| 126 | jamb_subjects = schema.Text( |
---|
| 127 | title = _(u'Subjects and Scores'), |
---|
| 128 | required = False, |
---|
| 129 | ) |
---|
| 130 | jamb_score = schema.Int( |
---|
| 131 | title = _(u'Total JAMB Score'), |
---|
| 132 | required = False, |
---|
| 133 | ) |
---|
| 134 | notice = schema.Text( |
---|
| 135 | title = _(u'Notice'), |
---|
| 136 | required = False, |
---|
| 137 | ) |
---|
| 138 | screening_venue = schema.TextLine( |
---|
| 139 | title = _(u'Screening Venue'), |
---|
| 140 | required = False, |
---|
| 141 | ) |
---|
| 142 | screening_date = schema.TextLine( |
---|
| 143 | title = _(u'Screening Date'), |
---|
| 144 | required = False, |
---|
| 145 | ) |
---|
| 146 | screening_score = schema.Int( |
---|
| 147 | title = _(u'Screening Score (%)'), |
---|
| 148 | required = False, |
---|
| 149 | ) |
---|
| 150 | aggregate = schema.Int( |
---|
| 151 | title = _(u'Aggregate Score (%)'), |
---|
| 152 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 153 | required = False, |
---|
| 154 | ) |
---|
| 155 | result_uploaded = schema.Bool( |
---|
| 156 | title = _(u'Result uploaded'), |
---|
| 157 | default = False, |
---|
| 158 | ) |
---|
| 159 | student_id = schema.TextLine( |
---|
| 160 | title = _(u'Student Id'), |
---|
| 161 | required = False, |
---|
| 162 | readonly = False, |
---|
| 163 | ) |
---|
| 164 | course_admitted = schema.Choice( |
---|
| 165 | title = _(u'Admitted Course of Study'), |
---|
| 166 | source = CertificateSource(), |
---|
| 167 | required = False, |
---|
| 168 | ) |
---|
| 169 | locked = schema.Bool( |
---|
| 170 | title = _(u'Form locked'), |
---|
| 171 | default = False, |
---|
| 172 | ) |
---|
| 173 | |
---|
[10217] | 174 | @invariant |
---|
| 175 | def second_choice(applicant): |
---|
| 176 | if applicant.course1 == applicant.course2: |
---|
| 177 | raise Invalid(_("2nd choice course must differ from 1st choice course.")) |
---|
[10204] | 178 | |
---|
[10088] | 179 | class ICustomPGApplicant(IApplicantBaseData): |
---|
[7853] | 180 | """A postgraduate applicant. |
---|
| 181 | |
---|
[8519] | 182 | This interface defines the least common multiple of all fields |
---|
| 183 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 184 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 185 | """ |
---|
| 186 | |
---|
[10088] | 187 | nationality = schema.Choice( |
---|
| 188 | source = nats_vocab, |
---|
| 189 | title = _(u'Nationality'), |
---|
| 190 | required = True, |
---|
| 191 | ) |
---|
| 192 | lga = schema.Choice( |
---|
| 193 | source = LGASource(), |
---|
| 194 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 195 | required = False, |
---|
| 196 | ) |
---|
| 197 | perm_address = schema.Text( |
---|
| 198 | title = _(u'Permanent Address'), |
---|
| 199 | required = False, |
---|
| 200 | ) |
---|
| 201 | course1 = schema.Choice( |
---|
| 202 | title = _(u'Programme desired'), |
---|
| 203 | source = AppCatCertificateSource(), |
---|
| 204 | required = True, |
---|
| 205 | ) |
---|
| 206 | notice = schema.Text( |
---|
| 207 | title = _(u'Notice'), |
---|
| 208 | required = False, |
---|
| 209 | readonly = False, |
---|
| 210 | ) |
---|
| 211 | #screening_venue = schema.TextLine( |
---|
| 212 | # title = _(u'Screening Venue'), |
---|
| 213 | # required = False, |
---|
| 214 | # ) |
---|
| 215 | #screening_date = schema.TextLine( |
---|
| 216 | # title = _(u'Screening Date'), |
---|
| 217 | # required = False, |
---|
| 218 | # ) |
---|
| 219 | #screening_score = schema.Int( |
---|
| 220 | # title = _(u'Screening Score (%)'), |
---|
| 221 | # required = False, |
---|
| 222 | # ) |
---|
| 223 | student_id = schema.TextLine( |
---|
| 224 | title = _(u'Student Id'), |
---|
| 225 | required = False, |
---|
| 226 | readonly = False, |
---|
| 227 | ) |
---|
| 228 | course_admitted = schema.Choice( |
---|
| 229 | title = _(u'Admitted Course of Study'), |
---|
| 230 | source = CertificateSource(), |
---|
| 231 | required = False, |
---|
| 232 | readonly = False, |
---|
| 233 | ) |
---|
| 234 | locked = schema.Bool( |
---|
| 235 | title = _(u'Form locked'), |
---|
| 236 | default = False, |
---|
| 237 | ) |
---|
| 238 | |
---|
[8932] | 239 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
[8012] | 240 | """An interface for both types of applicants. |
---|
| 241 | |
---|
[8932] | 242 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 243 | by ICustomPGApplicant field settings. If a field is defined |
---|
[8730] | 244 | in both interfaces zope.schema validates only against the |
---|
[8932] | 245 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 246 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
[8012] | 247 | """ |
---|
| 248 | |
---|
[8744] | 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 | |
---|
[10096] | 258 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[8730] | 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 | |
---|
[10217] | 270 | course1 = schema.Choice( |
---|
| 271 | title = _(u'1st Choice Course of Study'), |
---|
| 272 | source = AppCatCertificateSource(), |
---|
| 273 | required = True, |
---|
| 274 | readonly = True, |
---|
| 275 | ) |
---|
| 276 | |
---|
| 277 | course2 = schema.Choice( |
---|
| 278 | title = _(u'2nd Choice Course of Study'), |
---|
| 279 | description = _(u'Comment which explains why applicant must select a 2nd Choice Course of Study.'), |
---|
| 280 | source = AppCatCertificateSource(), |
---|
| 281 | required = True, |
---|
| 282 | ) |
---|
| 283 | |
---|
[10096] | 284 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
---|
[7866] | 285 | """A postgraduate applicant interface for editing. |
---|
| 286 | |
---|
| 287 | Here we can repeat the fields from base data and set the |
---|
| 288 | `required` and `readonly` attributes to True to further restrict |
---|
| 289 | the data access. Or we can allow only certain certificates to be |
---|
| 290 | selected by choosing the appropriate source. |
---|
| 291 | |
---|
| 292 | We cannot omit fields here. This has to be done in the |
---|
| 293 | respective form page. |
---|
[8017] | 294 | """ |
---|
[8454] | 295 | |
---|
[10096] | 296 | |
---|
[8932] | 297 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
[8247] | 298 | """An applicant payment via payment gateways. |
---|
| 299 | |
---|
| 300 | """ |
---|
[8530] | 301 | |
---|
[8981] | 302 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
[8582] | 303 | """Representation of an applicant. |
---|
| 304 | |
---|
| 305 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 306 | the applicant object. |
---|
| 307 | """ |
---|
[8981] | 308 | |
---|