[7853] | 1 | ## $Id: interfaces.py 8521 2012-05-25 10:33:48Z 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 |
---|
[8247] | 26 | from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab |
---|
[8184] | 27 | from waeup.kofa.schema import FormattedDate |
---|
[8071] | 28 | from waeup.kofa.students.vocabularies import nats_vocab |
---|
[8444] | 29 | from waeup.aaue.interfaces import ( |
---|
[8503] | 30 | LGASource, high_qual, high_grade, exam_types) |
---|
[8444] | 31 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 32 | from waeup.aaue.payments.interfaces import ICustomOnlinePayment |
---|
[7853] | 33 | |
---|
[8521] | 34 | UG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
| 35 | UG_OMIT_MANAGE_FIELDS = () |
---|
| 36 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted', |
---|
| 37 | 'student_id', 'screening_score', 'screening_venue') |
---|
| 38 | |
---|
| 39 | PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
| 40 | PG_OMIT_MANAGE_FIELDS = () |
---|
| 41 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted', |
---|
| 42 | 'student_id', 'screening_score', 'screening_venue') |
---|
| 43 | |
---|
[8053] | 44 | class IUGApplicant(IApplicantBaseData): |
---|
[8012] | 45 | """An undergraduate applicant. |
---|
| 46 | |
---|
[8521] | 47 | This interface defines the least common multiple of all fields |
---|
| 48 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 49 | adding them to the UG_OMIT* tuples. |
---|
[8012] | 50 | """ |
---|
| 51 | |
---|
[8071] | 52 | nationality = schema.Choice( |
---|
| 53 | source = nats_vocab, |
---|
| 54 | title = _(u'Nationality'), |
---|
| 55 | required = False, |
---|
| 56 | ) |
---|
| 57 | lga = schema.Choice( |
---|
[8503] | 58 | source = LGASource(), |
---|
[8071] | 59 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 60 | required = False, |
---|
| 61 | ) |
---|
| 62 | |
---|
| 63 | # This ordering doesn't work properly. |
---|
| 64 | IUGApplicant[ |
---|
| 65 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
| 66 | IUGApplicant[ |
---|
| 67 | 'lga'].order = IUGApplicant['nationality'].order |
---|
| 68 | |
---|
| 69 | |
---|
[8053] | 70 | class IPGApplicant(IApplicantBaseData): |
---|
[7853] | 71 | """A postgraduate applicant. |
---|
| 72 | |
---|
[8521] | 73 | This interface defines the least common multiple of all fields |
---|
| 74 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 75 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 76 | """ |
---|
| 77 | |
---|
[8071] | 78 | nationality = schema.Choice( |
---|
| 79 | source = nats_vocab, |
---|
| 80 | title = _(u'Nationality'), |
---|
| 81 | required = False, |
---|
| 82 | ) |
---|
| 83 | lga = schema.Choice( |
---|
[8503] | 84 | source = LGASource(), |
---|
[8071] | 85 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 86 | required = False, |
---|
| 87 | ) |
---|
[8051] | 88 | perm_address = schema.Text( |
---|
| 89 | title = _(u'Permanent Address'), |
---|
| 90 | required = False, |
---|
| 91 | ) |
---|
| 92 | course1 = schema.Choice( |
---|
| 93 | title = _(u'1st Choice Course of Study'), |
---|
| 94 | source = AppCatCertificateSource(), |
---|
| 95 | required = True, |
---|
| 96 | ) |
---|
| 97 | course2 = schema.Choice( |
---|
| 98 | title = _(u'2nd Choice Course of Study'), |
---|
| 99 | source = AppCatCertificateSource(), |
---|
| 100 | required = False, |
---|
| 101 | ) |
---|
| 102 | hq_type = schema.Choice( |
---|
| 103 | title = _(u'Qualification Obtained'), |
---|
| 104 | required = False, |
---|
| 105 | readonly = False, |
---|
| 106 | vocabulary = high_qual, |
---|
| 107 | ) |
---|
| 108 | hq_matric_no = schema.TextLine( |
---|
| 109 | title = _(u'Former Matric Number'), |
---|
| 110 | required = False, |
---|
| 111 | readonly = False, |
---|
| 112 | ) |
---|
| 113 | hq_degree = schema.Choice( |
---|
| 114 | title = _(u'Class of Degree'), |
---|
| 115 | required = False, |
---|
| 116 | readonly = False, |
---|
| 117 | vocabulary = high_grade, |
---|
| 118 | ) |
---|
| 119 | hq_school = schema.TextLine( |
---|
| 120 | title = _(u'Institution Attended'), |
---|
| 121 | required = False, |
---|
| 122 | readonly = False, |
---|
| 123 | ) |
---|
| 124 | hq_session = schema.TextLine( |
---|
| 125 | title = _(u'Years Attended'), |
---|
| 126 | required = False, |
---|
| 127 | readonly = False, |
---|
| 128 | ) |
---|
| 129 | hq_disc = schema.TextLine( |
---|
| 130 | title = _(u'Discipline'), |
---|
| 131 | required = False, |
---|
| 132 | readonly = False, |
---|
| 133 | ) |
---|
| 134 | pp_school = schema.Choice( |
---|
| 135 | title = _(u'Qualification Obtained'), |
---|
| 136 | required = False, |
---|
| 137 | readonly = False, |
---|
| 138 | vocabulary = exam_types, |
---|
| 139 | ) |
---|
[8101] | 140 | #presently = schema.Bool( |
---|
| 141 | # title = _(u'Attending'), |
---|
| 142 | # required = False, |
---|
| 143 | # readonly = False, |
---|
| 144 | # ) |
---|
| 145 | presently_inst = schema.TextLine( |
---|
| 146 | title = _(u'If yes, name of institution'), |
---|
| 147 | required = False, |
---|
| 148 | readonly = False, |
---|
| 149 | ) |
---|
| 150 | nysc_year = schema.Int( |
---|
| 151 | title = _(u'Nysc Year'), |
---|
| 152 | required = False, |
---|
| 153 | readonly = False, |
---|
| 154 | ) |
---|
| 155 | nysc_lga = schema.Choice( |
---|
[8503] | 156 | source = LGASource(), |
---|
[8101] | 157 | title = _(u'Nysc Location'), |
---|
| 158 | required = False, |
---|
| 159 | ) |
---|
[8012] | 160 | employer = schema.TextLine( |
---|
| 161 | title = _(u'Employer'), |
---|
| 162 | required = False, |
---|
| 163 | readonly = False, |
---|
| 164 | ) |
---|
[8051] | 165 | emp_position = schema.TextLine( |
---|
| 166 | title = _(u'Employer Position'), |
---|
| 167 | required = False, |
---|
| 168 | readonly = False, |
---|
| 169 | ) |
---|
[8184] | 170 | emp_start = FormattedDate( |
---|
[8051] | 171 | title = _(u'Start Date'), |
---|
| 172 | required = False, |
---|
| 173 | readonly = False, |
---|
[8378] | 174 | show_year = True, |
---|
[8051] | 175 | ) |
---|
[8184] | 176 | emp_end = FormattedDate( |
---|
[8051] | 177 | title = _(u'End Date'), |
---|
| 178 | required = False, |
---|
| 179 | readonly = False, |
---|
[8378] | 180 | show_year = True, |
---|
[8051] | 181 | ) |
---|
| 182 | emp_reason = schema.TextLine( |
---|
| 183 | title = _(u'Reason for Leaving'), |
---|
| 184 | required = False, |
---|
| 185 | readonly = False, |
---|
| 186 | ) |
---|
| 187 | employer2 = schema.TextLine( |
---|
| 188 | title = _(u'2nd Employer'), |
---|
| 189 | required = False, |
---|
| 190 | readonly = False, |
---|
| 191 | ) |
---|
| 192 | emp2_position = schema.TextLine( |
---|
| 193 | title = _(u'2nd Employer Position'), |
---|
| 194 | required = False, |
---|
| 195 | readonly = False, |
---|
| 196 | ) |
---|
[8184] | 197 | emp2_start = FormattedDate( |
---|
[8051] | 198 | title = _(u'Start Date'), |
---|
| 199 | required = False, |
---|
| 200 | readonly = False, |
---|
[8378] | 201 | show_year = True, |
---|
[8051] | 202 | ) |
---|
[8184] | 203 | emp2_end = FormattedDate( |
---|
[8051] | 204 | title = _(u'End Date'), |
---|
| 205 | required = False, |
---|
| 206 | readonly = False, |
---|
[8378] | 207 | show_year = True, |
---|
[8051] | 208 | ) |
---|
| 209 | emp2_reason = schema.TextLine( |
---|
| 210 | title = _(u'Reason for Leaving'), |
---|
| 211 | required = False, |
---|
| 212 | readonly = False, |
---|
| 213 | ) |
---|
| 214 | notice = schema.Text( |
---|
| 215 | title = _(u'Notice'), |
---|
| 216 | required = False, |
---|
| 217 | readonly = False, |
---|
| 218 | ) |
---|
| 219 | screening_venue = schema.TextLine( |
---|
| 220 | title = _(u'Screening Venue'), |
---|
| 221 | required = False, |
---|
| 222 | readonly = False, |
---|
| 223 | ) |
---|
| 224 | screening_score = schema.Int( |
---|
| 225 | title = _(u'Screening Score'), |
---|
| 226 | required = False, |
---|
| 227 | readonly = False, |
---|
| 228 | ) |
---|
| 229 | course_admitted = schema.Choice( |
---|
| 230 | title = _(u'Admitted Course of Study'), |
---|
| 231 | source = CertificateSource(), |
---|
| 232 | required = False, |
---|
| 233 | readonly = False, |
---|
| 234 | ) |
---|
[8012] | 235 | |
---|
[8051] | 236 | |
---|
[8071] | 237 | # This ordering doesn't work properly. |
---|
[8051] | 238 | IPGApplicant[ |
---|
[8071] | 239 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
| 240 | IPGApplicant[ |
---|
| 241 | 'lga'].order = IPGApplicant['nationality'].order |
---|
| 242 | IPGApplicant[ |
---|
[8051] | 243 | 'student_id'].order = IPGApplicant['notice'].order |
---|
| 244 | |
---|
[8071] | 245 | |
---|
[8196] | 246 | class ICustomApplicant(IUGApplicant,IPGApplicant): |
---|
[8012] | 247 | """An interface for both types of applicants. |
---|
| 248 | |
---|
| 249 | """ |
---|
| 250 | |
---|
[8053] | 251 | def loggerInfo(ob_class, comment): |
---|
| 252 | """Adds an INFO message to the log file |
---|
| 253 | """ |
---|
| 254 | |
---|
| 255 | def createStudent(): |
---|
| 256 | """Create a student object from applicatnt data |
---|
| 257 | and copy applicant object. |
---|
| 258 | """ |
---|
| 259 | |
---|
[8017] | 260 | class IUGApplicantEdit(IUGApplicant): |
---|
[8012] | 261 | """An undergraduate applicant interface for editing. |
---|
| 262 | |
---|
| 263 | Here we can repeat the fields from base data and set the |
---|
| 264 | `required` and `readonly` attributes to True to further restrict |
---|
| 265 | the data access. Or we can allow only certain certificates to be |
---|
| 266 | selected by choosing the appropriate source. |
---|
| 267 | |
---|
| 268 | We cannot omit fields here. This has to be done in the |
---|
| 269 | respective form page. |
---|
| 270 | """ |
---|
| 271 | |
---|
[8017] | 272 | class IPGApplicantEdit(IPGApplicant): |
---|
[7866] | 273 | """A postgraduate applicant interface for editing. |
---|
| 274 | |
---|
| 275 | Here we can repeat the fields from base data and set the |
---|
| 276 | `required` and `readonly` attributes to True to further restrict |
---|
| 277 | the data access. Or we can allow only certain certificates to be |
---|
| 278 | selected by choosing the appropriate source. |
---|
| 279 | |
---|
| 280 | We cannot omit fields here. This has to be done in the |
---|
| 281 | respective form page. |
---|
[8017] | 282 | """ |
---|
[8455] | 283 | |
---|
[8247] | 284 | class ICustomApplicantOnlinePayment(ICustomOnlinePayment): |
---|
| 285 | """An applicant payment via payment gateways. |
---|
| 286 | |
---|
| 287 | """ |
---|