[10298] | 1 | ## $Id: browser.py 14209 2016-09-30 11:04:24Z 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 | """UI components for basic applicants and related components. |
---|
| 19 | """ |
---|
| 20 | import grok |
---|
| 21 | import os |
---|
[13996] | 22 | from zope.component import getUtility, getAdapter |
---|
| 23 | from zope.i18n import translate |
---|
[14027] | 24 | from hurry.workflow.interfaces import IWorkflowState |
---|
[10298] | 25 | from waeup.kofa.interfaces import ( |
---|
[13996] | 26 | IExtFileStore, IFileStoreNameChooser, IKofaUtils) |
---|
[10298] | 27 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
| 28 | from waeup.kofa.utils.helpers import string_from_bytes, file_size |
---|
[13996] | 29 | from waeup.kofa.applicants.browser import ( |
---|
| 30 | ApplicantCheckStatusPage, ApplicantBaseDisplayFormPage) |
---|
[14027] | 31 | from waeup.kofa.applicants.workflow import STARTED, PAID |
---|
[13538] | 32 | from waeup.kofa.applicants.viewlets import PDFActionButton |
---|
[13996] | 33 | from waeup.kofa.browser.layout import UtilityView |
---|
| 34 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
| 35 | from waeup.kofa.interfaces import IPDF |
---|
[13997] | 36 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
[10298] | 37 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 38 | from kofacustom.nigeria.applicants.browser import ( |
---|
| 39 | NigeriaApplicantDisplayFormPage, |
---|
| 40 | NigeriaApplicantManageFormPage, |
---|
| 41 | NigeriaApplicantEditFormPage, |
---|
| 42 | NigeriaPDFApplicationSlip, |
---|
[10929] | 43 | NigeriaApplicantRegistrationPage, |
---|
[11755] | 44 | NigeriaExportPDFPaymentSlipPage, |
---|
[13545] | 45 | ) |
---|
| 46 | from kofacustom.nigeria.applicants.interfaces import OMIT_DISPLAY_FIELDS |
---|
[10298] | 47 | from waeup.aaue.applicants.interfaces import ( |
---|
| 48 | ICustomUGApplicant, |
---|
[13544] | 49 | ICustomUGApplicantEdit, |
---|
[13996] | 50 | ITranscriptApplicant, |
---|
| 51 | ICustomApplicant |
---|
[11291] | 52 | ) |
---|
[10298] | 53 | |
---|
[13545] | 54 | UG_OMIT_FIELDS = ( |
---|
| 55 | 'hq_type', 'hq_fname', 'hq_matric_no', |
---|
| 56 | 'hq_degree', 'hq_school', 'hq_session', 'hq_disc', |
---|
| 57 | 'hq_type2', 'hq_fname2', 'hq_matric_no2', |
---|
| 58 | 'hq_degree2', 'hq_school2', 'hq_session2', 'hq_disc2', |
---|
| 59 | 'hq_type3', 'hq_fname3', 'hq_matric_no3', |
---|
[13679] | 60 | 'hq_degree3', 'hq_school3', 'hq_session3', 'hq_disc3', |
---|
| 61 | 'nysc_year', |
---|
| 62 | 'nysc_location', |
---|
| 63 | 'nysc_lga', |
---|
| 64 | 'employer', |
---|
| 65 | 'emp_position', |
---|
| 66 | 'emp_start', |
---|
| 67 | 'emp_end', |
---|
| 68 | 'emp_reason', |
---|
| 69 | 'employer2', |
---|
| 70 | 'emp2_position', |
---|
| 71 | 'emp2_start', |
---|
| 72 | 'emp2_end', |
---|
| 73 | 'emp2_reason', |
---|
| 74 | 'former_matric', |
---|
[13545] | 75 | ) |
---|
[13546] | 76 | UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
[13977] | 77 | 'jamb_subjects_list', 'master_sheet_number') + UG_OMIT_FIELDS |
---|
[13545] | 78 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + UG_OMIT_FIELDS + ( |
---|
| 79 | 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
| 80 | 'alr_results', 'notice') |
---|
[13546] | 81 | UG_OMIT_MANAGE_FIELDS = ( |
---|
| 82 | 'special_application','jamb_subjects_list',) + UG_OMIT_FIELDS |
---|
| 83 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
[13545] | 84 | 'student_id', |
---|
| 85 | 'notice', |
---|
| 86 | 'jamb_age', |
---|
| 87 | 'jamb_subjects', |
---|
| 88 | 'jamb_score', |
---|
| 89 | 'jamb_reg_number', |
---|
[13679] | 90 | 'aggregate', |
---|
[13977] | 91 | 'master_sheet_number', |
---|
[13996] | 92 | 'screening_venue', |
---|
| 93 | 'screening_score', |
---|
| 94 | 'screening_date' |
---|
[13679] | 95 | ) |
---|
[10298] | 96 | |
---|
[14209] | 97 | UDE_OMIT_FIELDS = ( |
---|
| 98 | 'nysc_year', |
---|
| 99 | 'nysc_location', |
---|
| 100 | 'nysc_lga', |
---|
| 101 | 'employer', |
---|
| 102 | 'emp_position', |
---|
| 103 | 'emp_start', |
---|
| 104 | 'emp_end', |
---|
| 105 | 'emp_reason', |
---|
| 106 | 'employer2', |
---|
| 107 | 'emp2_position', |
---|
| 108 | 'emp2_start', |
---|
| 109 | 'emp2_end', |
---|
| 110 | 'emp2_reason', |
---|
| 111 | 'former_matric', |
---|
| 112 | ) |
---|
| 113 | UDE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
| 114 | 'jamb_subjects_list', 'master_sheet_number') + UDE_OMIT_FIELDS |
---|
| 115 | UDE_OMIT_PDF_FIELDS = UDE_OMIT_DISPLAY_FIELDS + UDE_OMIT_FIELDS + ( |
---|
| 116 | 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
| 117 | 'alr_results', 'notice') |
---|
| 118 | UDE_OMIT_MANAGE_FIELDS = ( |
---|
| 119 | 'special_application','jamb_subjects_list',) + UDE_OMIT_FIELDS |
---|
| 120 | UDE_OMIT_EDIT_FIELDS = UDE_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
| 121 | 'student_id', |
---|
| 122 | 'notice', |
---|
| 123 | 'jamb_age', |
---|
| 124 | 'jamb_subjects', |
---|
| 125 | 'jamb_score', |
---|
| 126 | 'jamb_reg_number', |
---|
| 127 | 'aggregate', |
---|
| 128 | 'master_sheet_number', |
---|
| 129 | 'screening_venue', |
---|
| 130 | 'screening_score', |
---|
| 131 | 'screening_date' |
---|
| 132 | ) |
---|
| 133 | |
---|
[13545] | 134 | #UG_OMIT_PDF_FIELDS = tuple([ |
---|
| 135 | # element for element in UG_OMIT_PDF_FIELDS if not element == 'phone']) |
---|
[11291] | 136 | |
---|
[13545] | 137 | #UG_OMIT_PDF_FIELDS += ( |
---|
| 138 | # 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
| 139 | # 'alr_results', 'notice' |
---|
| 140 | # ) |
---|
[13538] | 141 | |
---|
[13545] | 142 | PG_OMIT_FIELDS = ( |
---|
| 143 | 'fst_sit_fname', |
---|
| 144 | 'fst_sit_no', |
---|
| 145 | 'fst_sit_date', |
---|
| 146 | 'fst_sit_type', |
---|
| 147 | 'fst_sit_results', |
---|
| 148 | 'scd_sit_fname', |
---|
| 149 | 'scd_sit_no', |
---|
| 150 | 'scd_sit_date', |
---|
| 151 | 'scd_sit_type', |
---|
| 152 | 'scd_sit_results', |
---|
[13977] | 153 | #'programme_type', |
---|
[13546] | 154 | 'jamb_age', |
---|
| 155 | 'jamb_subjects', |
---|
| 156 | 'jamb_score', |
---|
| 157 | 'jamb_reg_number', |
---|
| 158 | 'aggregate' |
---|
[13545] | 159 | ) |
---|
| 160 | PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
| 161 | 'jamb_subjects_list',) + PG_OMIT_FIELDS |
---|
| 162 | PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + PG_OMIT_FIELDS + ( |
---|
| 163 | 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
[13679] | 164 | 'alr_results', 'notice', |
---|
| 165 | 'nysc_year', |
---|
| 166 | 'nysc_location', |
---|
| 167 | 'nysc_lga', |
---|
| 168 | 'former_matric', |
---|
| 169 | ) |
---|
[13545] | 170 | PG_OMIT_MANAGE_FIELDS = ( |
---|
| 171 | 'special_application','jamb_subjects_list',) + PG_OMIT_FIELDS |
---|
[13546] | 172 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
[13545] | 173 | 'student_id', |
---|
| 174 | 'notice', |
---|
[13546] | 175 | ) |
---|
[13545] | 176 | |
---|
[13679] | 177 | PTEE_OMIT_FIELDS = ( |
---|
| 178 | 'jamb_age', |
---|
| 179 | 'jamb_subjects', |
---|
| 180 | 'jamb_score', |
---|
| 181 | 'jamb_reg_number', |
---|
| 182 | 'aggregate' |
---|
| 183 | ) |
---|
| 184 | PTEE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
| 185 | 'jamb_subjects_list',) + PTEE_OMIT_FIELDS |
---|
| 186 | PTEE_OMIT_PDF_FIELDS = PTEE_OMIT_DISPLAY_FIELDS + PTEE_OMIT_FIELDS + ( |
---|
| 187 | 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
| 188 | 'alr_results', 'notice', |
---|
| 189 | 'nysc_year', |
---|
| 190 | 'nysc_location', |
---|
| 191 | 'nysc_lga', |
---|
| 192 | 'employer', |
---|
| 193 | 'emp_position', |
---|
| 194 | 'emp_start', |
---|
| 195 | 'emp_end', |
---|
| 196 | 'emp_reason', |
---|
| 197 | 'employer2', |
---|
| 198 | 'emp2_position', |
---|
| 199 | 'emp2_start', |
---|
| 200 | 'emp2_end', |
---|
| 201 | 'emp2_reason', |
---|
| 202 | 'former_matric', |
---|
| 203 | ) |
---|
| 204 | PTEE_OMIT_MANAGE_FIELDS = ( |
---|
| 205 | 'special_application','jamb_subjects_list',) + PTEE_OMIT_FIELDS |
---|
| 206 | PTEE_OMIT_EDIT_FIELDS = PTEE_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
| 207 | 'student_id', |
---|
| 208 | 'notice', |
---|
| 209 | ) |
---|
| 210 | |
---|
[14150] | 211 | UPDATE_OMIT_FIELDS = ( |
---|
| 212 | 'firstname', |
---|
| 213 | 'middlename', |
---|
| 214 | 'lastname', |
---|
| 215 | 'sex', |
---|
| 216 | 'lga', |
---|
| 217 | 'course1', |
---|
| 218 | ) |
---|
| 219 | |
---|
[10298] | 220 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
| 221 | """A display view for applicant data. |
---|
| 222 | """ |
---|
| 223 | |
---|
| 224 | @property |
---|
| 225 | def form_fields(self): |
---|
[13538] | 226 | if self.target is not None and self.target == 'trans': |
---|
[13544] | 227 | form_fields = grok.AutoFields(ITranscriptApplicant).omit( |
---|
| 228 | 'locked', 'suspended') |
---|
| 229 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
| 230 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 231 | return form_fields |
---|
[13538] | 232 | # AAUE is using the same interface for all regular applications. |
---|
[11291] | 233 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
[13538] | 234 | if self.target is not None and self.target.startswith('pg'): |
---|
| 235 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
| 236 | form_fields = form_fields.omit(field) |
---|
[14150] | 237 | elif self.target is not None and self.target in ('ptee',): |
---|
[13679] | 238 | for field in PTEE_OMIT_DISPLAY_FIELDS: |
---|
[10298] | 239 | form_fields = form_fields.omit(field) |
---|
[14209] | 240 | elif self.target is not None and self.target in ('ude',): |
---|
| 241 | for field in UDE_OMIT_DISPLAY_FIELDS: |
---|
| 242 | form_fields = form_fields.omit(field) |
---|
[10298] | 243 | else: |
---|
| 244 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
| 245 | form_fields = form_fields.omit(field) |
---|
| 246 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 247 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 248 | if not getattr(self.context, 'student_id'): |
---|
| 249 | form_fields = form_fields.omit('student_id') |
---|
| 250 | if not getattr(self.context, 'screening_score'): |
---|
| 251 | form_fields = form_fields.omit('screening_score') |
---|
| 252 | if not getattr(self.context, 'screening_venue'): |
---|
| 253 | form_fields = form_fields.omit('screening_venue') |
---|
| 254 | if not getattr(self.context, 'screening_date'): |
---|
| 255 | form_fields = form_fields.omit('screening_date') |
---|
| 256 | return form_fields |
---|
| 257 | |
---|
[13538] | 258 | class CustomPDFActionButton(PDFActionButton): |
---|
| 259 | |
---|
| 260 | @property |
---|
| 261 | def target_url(self): |
---|
[13540] | 262 | if self.context.state in ('initialized', 'started', 'paid') \ |
---|
[13541] | 263 | or self.context.special or self.view.target == 'trans': |
---|
[13540] | 264 | return |
---|
| 265 | return self.view.url(self.view.context, self.target) |
---|
[13538] | 266 | |
---|
| 267 | |
---|
[10298] | 268 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
| 269 | |
---|
[10311] | 270 | column_two_fields = ('applicant_id', 'reg_number', |
---|
| 271 | 'firstname', 'middlename', 'lastname', 'sex', 'date_of_birth') |
---|
[13679] | 272 | #two_columns_design_fields = [ |
---|
| 273 | # 'fst_sit_fname', 'fst_sit_no', 'fst_sit_date', |
---|
| 274 | # 'fst_sit_type', 'fst_sit_results', |
---|
| 275 | # 'scd_sit_fname', 'scd_sit_no', 'scd_sit_date', |
---|
| 276 | # 'scd_sit_type', 'scd_sit_results'] |
---|
[10311] | 277 | |
---|
[10301] | 278 | @property |
---|
| 279 | def note(self): |
---|
[14057] | 280 | note = getattr(self.context.__parent__, 'application_slip_notice', None) |
---|
| 281 | if note: |
---|
| 282 | return '<br /><br />' + note |
---|
[10301] | 283 | if self.context.sex == 'm': |
---|
| 284 | pronoun = 'he' |
---|
| 285 | else: |
---|
| 286 | pronoun = 'she' |
---|
| 287 | return ''' |
---|
[10897] | 288 | The applicant has acknowledged that, if discovered at any time that %s does not possess |
---|
| 289 | any of the qualifications which %s claims %s has obtained, %s will be expelled from the |
---|
| 290 | University not be re-admitted for the same or any other programme, even if %s has |
---|
| 291 | upgraded previous and shall qualifications or possess additional qualifications. |
---|
[10331] | 292 | ''' % ( |
---|
[10301] | 293 | pronoun, pronoun, pronoun, pronoun, pronoun) |
---|
[10298] | 294 | |
---|
| 295 | @property |
---|
| 296 | def form_fields(self): |
---|
[13538] | 297 | # AAUE is using the same interface for all regular applications. |
---|
[11291] | 298 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
[13538] | 299 | if self.target is not None and self.target.startswith('pg'): |
---|
| 300 | for field in PG_OMIT_PDF_FIELDS: |
---|
| 301 | form_fields = form_fields.omit(field) |
---|
[14150] | 302 | elif self.target is not None and self.target in ('ptee',): |
---|
[13679] | 303 | for field in PTEE_OMIT_PDF_FIELDS: |
---|
[10298] | 304 | form_fields = form_fields.omit(field) |
---|
[14209] | 305 | elif self.target is not None and self.target in ('ude',): |
---|
| 306 | for field in UDE_OMIT_PDF_FIELDS: |
---|
| 307 | form_fields = form_fields.omit(field) |
---|
[10298] | 308 | else: |
---|
| 309 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 310 | form_fields = form_fields.omit(field) |
---|
| 311 | if not getattr(self.context, 'student_id'): |
---|
| 312 | form_fields = form_fields.omit('student_id') |
---|
| 313 | if not getattr(self.context, 'screening_score'): |
---|
| 314 | form_fields = form_fields.omit('screening_score') |
---|
| 315 | if not getattr(self.context, 'screening_venue'): |
---|
| 316 | form_fields = form_fields.omit('screening_venue') |
---|
| 317 | if not getattr(self.context, 'screening_date'): |
---|
| 318 | form_fields = form_fields.omit('screening_date') |
---|
| 319 | return form_fields |
---|
| 320 | |
---|
| 321 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
| 322 | """A full edit view for applicant data. |
---|
| 323 | """ |
---|
| 324 | |
---|
| 325 | @property |
---|
| 326 | def form_fields(self): |
---|
[13538] | 327 | if self.target is not None and self.target == 'trans': |
---|
[13544] | 328 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[13538] | 329 | form_fields['applicant_id'].for_display = True |
---|
| 330 | return form_fields |
---|
| 331 | # AAUE is using the same interface for all regular applications. |
---|
[11291] | 332 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
[13538] | 333 | if self.target is not None and self.target.startswith('pg'): |
---|
| 334 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
| 335 | form_fields = form_fields.omit(field) |
---|
[14150] | 336 | elif self.target is not None and self.target in ('ptee',): |
---|
[13679] | 337 | for field in PTEE_OMIT_MANAGE_FIELDS: |
---|
[10298] | 338 | form_fields = form_fields.omit(field) |
---|
[14209] | 339 | elif self.target is not None and self.target in ('ude',): |
---|
| 340 | for field in UDE_OMIT_MANAGE_FIELDS: |
---|
| 341 | form_fields = form_fields.omit(field) |
---|
[10298] | 342 | else: |
---|
| 343 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 344 | form_fields = form_fields.omit(field) |
---|
| 345 | form_fields['student_id'].for_display = True |
---|
| 346 | form_fields['applicant_id'].for_display = True |
---|
| 347 | return form_fields |
---|
| 348 | |
---|
| 349 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
| 350 | """An applicant-centered edit view for applicant data. |
---|
| 351 | """ |
---|
| 352 | |
---|
[13547] | 353 | grok.template('applicanteditpage') |
---|
[13541] | 354 | |
---|
[14027] | 355 | def unremovable(self, ticket): |
---|
| 356 | return True |
---|
| 357 | |
---|
| 358 | # AAUE applicants never see the 'Remove Selected Tickets' button. |
---|
[10298] | 359 | @property |
---|
[14027] | 360 | def display_actions(self): |
---|
| 361 | state = IWorkflowState(self.context).getState() |
---|
| 362 | # If the form is unlocked, applicants are allowed to save the form |
---|
[14029] | 363 | # and remove unused tickets. |
---|
| 364 | actions = [[_('Save')], []] |
---|
[14027] | 365 | # Only in state started they can also add tickets. |
---|
| 366 | if state == STARTED: |
---|
[14029] | 367 | actions = [[_('Save')], |
---|
| 368 | [_('Add online payment ticket')]] |
---|
[14027] | 369 | # In state paid, they can submit the data and further add tickets |
---|
| 370 | # if the application is special. |
---|
| 371 | elif self.context.special and state == PAID: |
---|
| 372 | actions = [[_('Save'), _('Finally Submit')], |
---|
[14029] | 373 | [_('Add online payment ticket')]] |
---|
[14027] | 374 | elif state == PAID: |
---|
[14029] | 375 | actions = [[_('Save'), _('Finally Submit')], []] |
---|
[14027] | 376 | return actions |
---|
| 377 | |
---|
| 378 | @property |
---|
[10298] | 379 | def form_fields(self): |
---|
[13538] | 380 | if self.target is not None and self.target == 'trans': |
---|
[13544] | 381 | form_fields = grok.AutoFields(ITranscriptApplicant).omit( |
---|
| 382 | 'locked', 'suspended') |
---|
[13538] | 383 | form_fields['applicant_id'].for_display = True |
---|
| 384 | return form_fields |
---|
| 385 | # AAUE is using the same interface for all regular applications. |
---|
[11291] | 386 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
[13538] | 387 | if self.target is not None and self.target.startswith('pg'): |
---|
| 388 | for field in PG_OMIT_EDIT_FIELDS: |
---|
| 389 | form_fields = form_fields.omit(field) |
---|
[14150] | 390 | elif self.target is not None and self.target in ('ptee',): |
---|
[13679] | 391 | for field in PTEE_OMIT_EDIT_FIELDS: |
---|
[10298] | 392 | form_fields = form_fields.omit(field) |
---|
[14209] | 393 | elif self.target is not None and self.target in ('ude',): |
---|
| 394 | for field in UDE_OMIT_EDIT_FIELDS: |
---|
| 395 | form_fields = form_fields.omit(field) |
---|
[10298] | 396 | else: |
---|
| 397 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 398 | form_fields = form_fields.omit(field) |
---|
[14150] | 399 | # Additional omissions |
---|
| 400 | if self.target is not None and self.target in ('ude', 'utme'): |
---|
| 401 | for field in UPDATE_OMIT_FIELDS: |
---|
| 402 | form_fields[field].for_display = True |
---|
[10298] | 403 | form_fields['applicant_id'].for_display = True |
---|
| 404 | form_fields['reg_number'].for_display = True |
---|
| 405 | return form_fields |
---|
[10929] | 406 | |
---|
| 407 | class CustomApplicantRegistrationPage(NigeriaApplicantRegistrationPage): |
---|
| 408 | """Captcha'd registration page for applicants. |
---|
| 409 | """ |
---|
| 410 | |
---|
| 411 | def _redirect(self, email, password, applicant_id): |
---|
| 412 | # Forward email and credentials to landing page. |
---|
| 413 | self.redirect(self.url(self.context, 'registration_complete', |
---|
| 414 | data = dict(email=email, password=password, |
---|
| 415 | applicant_id=applicant_id))) |
---|
[11755] | 416 | return |
---|
| 417 | |
---|
| 418 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
| 419 | |
---|
| 420 | @property |
---|
| 421 | def payment_slip_download_warning(self): |
---|
[13422] | 422 | return '' |
---|
| 423 | |
---|
| 424 | class CustomApplicantCheckStatusPage(ApplicantCheckStatusPage): |
---|
| 425 | """Captcha'd status checking page for applicants. |
---|
| 426 | """ |
---|
| 427 | grok.template('applicantcheckstatus') |
---|
[13996] | 428 | |
---|
[13997] | 429 | class PaymentReceiptActionButton(ManageActionButton): |
---|
| 430 | grok.order(8) # This button should always be the last one. |
---|
| 431 | grok.context(ICustomApplicant) |
---|
| 432 | grok.view(CustomApplicantDisplayFormPage) |
---|
| 433 | grok.require('waeup.viewApplication') |
---|
| 434 | icon = 'actionicon_pdf.png' |
---|
| 435 | text = _('Download screening invitation letter') |
---|
| 436 | target = 'screening_invitation.pdf' |
---|
[13996] | 437 | |
---|
[13997] | 438 | @property |
---|
| 439 | def target_url(self): |
---|
| 440 | if not self.context.screening_date: |
---|
| 441 | return '' |
---|
| 442 | return self.view.url(self.view.context, self.target) |
---|
| 443 | |
---|
[13996] | 444 | class ExportScreeningInvitationLetter(UtilityView, grok.View): |
---|
| 445 | """Deliver a slip with only screening data. |
---|
| 446 | This form page is available only in AAUE. |
---|
| 447 | """ |
---|
[13997] | 448 | grok.context(ICustomApplicant) |
---|
[13996] | 449 | grok.name('screening_invitation.pdf') |
---|
| 450 | grok.require('waeup.viewApplication') |
---|
| 451 | prefix = 'form' |
---|
| 452 | |
---|
| 453 | label = u'Screening Invitation Letter' |
---|
| 454 | |
---|
| 455 | form_fields = [] |
---|
| 456 | |
---|
| 457 | @property |
---|
| 458 | def note(self): |
---|
| 459 | if self.context.screening_date: |
---|
[13999] | 460 | year = self.context.__parent__.year |
---|
| 461 | session = '%s/%s' % (year, year + 1) |
---|
| 462 | sdate = self.context.screening_date |
---|
| 463 | stime = '' |
---|
| 464 | if '@' in self.context.screening_date: |
---|
| 465 | sdate = self.context.screening_date.split('@')[0].strip() |
---|
| 466 | stime = self.context.screening_date.split('@')[1].strip() |
---|
[13996] | 467 | return """ |
---|
| 468 | <br /><br /><br /><br /><font size='12'> |
---|
| 469 | Dear %s, |
---|
| 470 | <br /><br /> |
---|
[13999] | 471 | You are invited to the Ambrose Alli University %s Admissions Screening Exercise. |
---|
[13996] | 472 | <br /><br /> |
---|
[13999] | 473 | <strong>Date: %s |
---|
[13996] | 474 | <br /><br /> |
---|
[13999] | 475 | Time: %s |
---|
| 476 | <br /><br /> |
---|
[13997] | 477 | Venue: %s |
---|
| 478 | </strong> |
---|
[13996] | 479 | <br /><br /> |
---|
[14015] | 480 | Please bring this letter of invitation and the downloaded application form along with you on your screening date. |
---|
| 481 | <br /><br /> |
---|
| 482 | You are expected to be available 30 minutes before the commencement of your Screening. |
---|
[13996] | 483 | </font> |
---|
| 484 | |
---|
[13999] | 485 | """ % ( |
---|
| 486 | self.context.display_fullname, |
---|
| 487 | session, |
---|
| 488 | sdate, |
---|
| 489 | stime, |
---|
[13996] | 490 | self.context.screening_venue) |
---|
| 491 | return |
---|
| 492 | |
---|
| 493 | @property |
---|
| 494 | def title(self): |
---|
| 495 | return None |
---|
| 496 | |
---|
| 497 | def update(self): |
---|
| 498 | if not self.context.screening_date: |
---|
| 499 | self.flash(_('Forbidden'), type="warning") |
---|
| 500 | self.redirect(self.url(self.context)) |
---|
| 501 | |
---|
| 502 | def render(self): |
---|
| 503 | applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) |
---|
| 504 | students_utils = getUtility(IStudentsUtils) |
---|
| 505 | return students_utils.renderPDF(self,'screening_data.pdf', |
---|
[14015] | 506 | self.context, applicantview, note=self.note) |
---|