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