[8911] | 1 | ## $Id: browser.py 17395 2023-04-27 11:37:37Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2012 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 | import grok |
---|
[17362] | 19 | import os |
---|
[16382] | 20 | from datetime import datetime |
---|
[8911] | 21 | from zope.i18n import translate |
---|
[13719] | 22 | from zope.security import checkPermission |
---|
[9210] | 23 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
[12856] | 24 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[9380] | 25 | from zope.component import getUtility |
---|
[9281] | 26 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[11069] | 27 | from waeup.kofa.interfaces import ( |
---|
| 28 | REQUESTED, IExtFileStore, IKofaUtils, IObjectHistory) |
---|
[8911] | 29 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[16782] | 30 | from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView, KofaPage |
---|
[9205] | 31 | from waeup.kofa.students.browser import ( |
---|
[15352] | 32 | StudentBaseEditFormPage, |
---|
[9686] | 33 | StudyLevelEditFormPage, StudyLevelDisplayFormPage, |
---|
[13063] | 34 | StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, |
---|
[16509] | 35 | CourseTicketDisplayFormPage, |
---|
| 36 | CourseTicketManageFormPage, |
---|
| 37 | StudentTriggerTransitionFormPage, |
---|
[11069] | 38 | msave, emit_lock_message, |
---|
[13063] | 39 | StudentActivateView, StudentDeactivateView, |
---|
[13719] | 40 | ExportPDFTranscriptSlip, |
---|
[15574] | 41 | PaymentsManageFormPage, |
---|
[16448] | 42 | StartClearancePage, |
---|
[16906] | 43 | StudentFilesUploadPage, |
---|
[17362] | 44 | StudyCourseTranscriptPage, |
---|
| 45 | ExportPDFAdmissionSlip) |
---|
[12845] | 46 | from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID, |
---|
| 47 | CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, |
---|
[16171] | 48 | GRADUATED, TRANSREQ, TRANSVAL, TRANSREL, FORBIDDEN_POSTGRAD_TRANS) |
---|
[9686] | 49 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
---|
[9251] | 50 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
[8911] | 51 | from kofacustom.nigeria.students.browser import ( |
---|
| 52 | NigeriaOnlinePaymentDisplayFormPage, |
---|
[9251] | 53 | NigeriaStudentBaseManageFormPage, |
---|
[9380] | 54 | NigeriaStudentClearanceEditFormPage, |
---|
[8911] | 55 | NigeriaOnlinePaymentAddFormPage, |
---|
[13063] | 56 | NigeriaExportPDFPaymentSlip, |
---|
| 57 | NigeriaExportPDFClearanceSlip, |
---|
[13297] | 58 | NigeriaExportPDFBedTicketSlip, |
---|
[12856] | 59 | NigeriaStudentPersonalDisplayFormPage, |
---|
[13085] | 60 | NigeriaStudentPersonalManageFormPage, |
---|
[15267] | 61 | NigeriaStudentPersonalEditFormPage, |
---|
[15371] | 62 | NigeriaAccommodationManageFormPage, |
---|
[15975] | 63 | NigeriaAccommodationDisplayFormPage, |
---|
[15371] | 64 | NigeriaStudentBaseDisplayFormPage, |
---|
[16361] | 65 | NigeriaStudentFilesUploadPage, |
---|
[9281] | 66 | ) |
---|
[9210] | 67 | from waeup.uniben.students.interfaces import ( |
---|
[12121] | 68 | ICustomStudent, |
---|
[15352] | 69 | ICustomStudentBase, |
---|
[12856] | 70 | ICustomStudentOnlinePayment, |
---|
| 71 | ICustomStudentStudyCourse, |
---|
[11552] | 72 | ICustomStudentStudyLevel, |
---|
| 73 | ICustomUGStudentClearance, |
---|
[12856] | 74 | ICustomPGStudentClearance, |
---|
[13085] | 75 | ICustomStudentPersonal, |
---|
[16382] | 76 | ICustomStudentPersonalEdit, |
---|
[16509] | 77 | IMedicalHistory, |
---|
[17395] | 78 | ITiship, |
---|
[16509] | 79 | ICustomCourseTicket) |
---|
[16793] | 80 | from waeup.uniben.students.deplinks import DEPLINKS |
---|
[9210] | 81 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8911] | 82 | |
---|
[15371] | 83 | class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage): |
---|
| 84 | """ Page to display student base data |
---|
| 85 | """ |
---|
| 86 | form_fields = grok.AutoFields(ICustomStudentBase).omit( |
---|
| 87 | 'password', 'suspended', 'suspended_comment', |
---|
[16088] | 88 | 'flash_notice', 'provisionally_cleared', 'parents_email') |
---|
[15371] | 89 | form_fields[ |
---|
| 90 | 'financial_clearance_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 91 | |
---|
[16088] | 92 | class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage): |
---|
| 93 | """ View to manage student base data |
---|
| 94 | """ |
---|
| 95 | form_fields = grok.AutoFields(ICustomStudentBase).omit( |
---|
| 96 | 'student_id', 'adm_code', 'suspended', |
---|
| 97 | 'financially_cleared_by', 'financial_clearance_date', |
---|
| 98 | 'parents_email') |
---|
[15371] | 99 | |
---|
[8911] | 100 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 101 | """ Page to view an online payment ticket |
---|
| 102 | """ |
---|
| 103 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 104 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9993] | 105 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 106 | form_fields[ |
---|
| 107 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 108 | form_fields[ |
---|
| 109 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 110 | |
---|
[15574] | 111 | class CustomStartClearancePage(StartClearancePage): |
---|
| 112 | |
---|
| 113 | @property |
---|
| 114 | def with_ac(self): |
---|
| 115 | if self.context.faccode == 'DCOEM': |
---|
| 116 | return False |
---|
| 117 | return True |
---|
| 118 | |
---|
[16452] | 119 | @property |
---|
| 120 | def portrait_uploaded(self): |
---|
| 121 | return True |
---|
[16363] | 122 | |
---|
[16452] | 123 | |
---|
[16363] | 124 | CLEARANCE_FLASH_MESSAGE = """ |
---|
| 125 | If you have not presented for physical clearance, scan your WAEC, NECO |
---|
[16364] | 126 | and other O level results scratch cards on one document and |
---|
| 127 | attach to the form below (Scans > O Level Results Scratch Card). |
---|
[16363] | 128 | Then come back to check for your successful cleared status as from 3 days |
---|
| 129 | after successful clearance request. |
---|
| 130 | If status is cleared, pay your school charges and proceed to the |
---|
| 131 | Dean's Office to collect the signed eligibility form. |
---|
| 132 | """ |
---|
| 133 | |
---|
[9380] | 134 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 135 | """ View to edit student clearance data by student |
---|
| 136 | """ |
---|
| 137 | |
---|
[11552] | 138 | @property |
---|
| 139 | def form_fields(self): |
---|
| 140 | if self.context.is_postgrad: |
---|
| 141 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( |
---|
[12391] | 142 | 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment', |
---|
| 143 | 'physical_clearance_date') |
---|
[11552] | 144 | else: |
---|
| 145 | form_fields = grok.AutoFields(ICustomUGStudentClearance).omit( |
---|
[12391] | 146 | 'clearance_locked', 'clr_code', 'officer_comment', |
---|
| 147 | 'physical_clearance_date') |
---|
[11552] | 148 | form_fields['date_of_birth'].for_display = True |
---|
| 149 | form_fields['nationality'].for_display = True |
---|
| 150 | form_fields['lga'].for_display = True |
---|
| 151 | return form_fields |
---|
| 152 | |
---|
[15666] | 153 | def dataNotComplete(self): |
---|
[9380] | 154 | store = getUtility(IExtFileStore) |
---|
[16458] | 155 | if self.context.entry_mode in ('ug_ft', 'de_ft') and \ |
---|
| 156 | not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
[16456] | 157 | return _('No red background passport picture uploaded.') |
---|
[9380] | 158 | if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'): |
---|
| 159 | return _('No birth certificate uploaded.') |
---|
| 160 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
| 161 | return _('No guarantor/referee letter uploaded.') |
---|
| 162 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
| 163 | return _('No acceptance letter uploaded.') |
---|
| 164 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
| 165 | return _('No first sitting result uploaded.') |
---|
| 166 | if not store.getFileByContext(self.context, attr=u'secr_cults.jpg'): |
---|
[9848] | 167 | return _('No affidavit of non-membership of secret cults uploaded.') |
---|
[16447] | 168 | if not store.getFileByContext(self.context, attr=u'olevel_sc.jpg'): |
---|
| 169 | return _('No O level results scratch card uploaded.') |
---|
[9380] | 170 | return False |
---|
| 171 | |
---|
[16447] | 172 | #def update(self): |
---|
| 173 | # self.flash(CLEARANCE_FLASH_MESSAGE, type="warning") |
---|
| 174 | # return super(CustomStudentClearanceEditFormPage, self).update() |
---|
[16363] | 175 | |
---|
[8911] | 176 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 177 | """ Page to add an online payment ticket |
---|
| 178 | """ |
---|
| 179 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
[15666] | 180 | 'p_combi') |
---|
[8911] | 181 | |
---|
[13063] | 182 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 183 | """Deliver a PDF slip of the context. |
---|
| 184 | """ |
---|
| 185 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 186 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[15688] | 187 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
[8911] | 188 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9205] | 189 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 190 | |
---|
| 191 | |
---|
[13063] | 192 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[9551] | 193 | """Deliver a PDF slip of the context. |
---|
| 194 | """ |
---|
| 195 | |
---|
[13303] | 196 | @property |
---|
| 197 | def omit_fields(self): |
---|
| 198 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
[13717] | 199 | 'phone', 'adm_code', 'email', 'date_of_birth', |
---|
| 200 | 'flash_notice') |
---|
[14902] | 201 | if self.context.is_jupeb: |
---|
[13303] | 202 | omit_fields += ('faculty', 'department') |
---|
| 203 | return omit_fields |
---|
[11537] | 204 | |
---|
[13299] | 205 | @property |
---|
| 206 | def label(self): |
---|
| 207 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13300] | 208 | line0 = '' |
---|
[14902] | 209 | if self.context.is_jupeb: |
---|
[13335] | 210 | line0 = 'Joint Universities Preliminary Examinations Board (JUPEB)\n' |
---|
[13300] | 211 | line1 = translate(_('Clearance Slip of'), |
---|
[13299] | 212 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 213 | + ' %s' % self.context.display_fullname |
---|
[13335] | 214 | return '%s%s' % (line0, line1) |
---|
[13299] | 215 | |
---|
[12846] | 216 | def _sigsInFooter(self): |
---|
[12845] | 217 | isStudent = getattr( |
---|
| 218 | self.request.principal, 'user_type', None) == 'student' |
---|
[12852] | 219 | if not isStudent and self.context.state in (CLEARED, RETURNING): |
---|
[12846] | 220 | return (_('Date, Student Signature'), |
---|
| 221 | _('Date, Clearance Officer Signature'), |
---|
| 222 | ) |
---|
| 223 | return () |
---|
[12845] | 224 | |
---|
[9551] | 225 | def render(self): |
---|
| 226 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 227 | self.request, self.omit_fields) |
---|
| 228 | students_utils = getUtility(IStudentsUtils) |
---|
| 229 | return students_utils.renderPDF( |
---|
| 230 | self, 'clearance_slip.pdf', |
---|
| 231 | self.context.student, studentview, signatures=self._signatures(), |
---|
[10271] | 232 | sigs_in_footer=self._sigsInFooter(), show_scans=False, |
---|
| 233 | omit_fields=self.omit_fields) |
---|
[9551] | 234 | |
---|
[12121] | 235 | |
---|
[13063] | 236 | class ExportClearanceInvitationSlip(UtilityView, grok.View): |
---|
[12121] | 237 | """Deliver an invitation letter to physical clearance. |
---|
| 238 | |
---|
| 239 | This form page is available only in Uniben. |
---|
| 240 | """ |
---|
| 241 | grok.context(ICustomStudent) |
---|
| 242 | grok.name('clearance_invitation_slip.pdf') |
---|
| 243 | grok.require('waeup.viewStudent') |
---|
| 244 | prefix = 'form' |
---|
| 245 | |
---|
[12263] | 246 | label = u'Invitation Letter for Physical Clearance' |
---|
[12121] | 247 | |
---|
| 248 | omit_fields = ( |
---|
| 249 | 'suspended', 'phone', 'email', |
---|
| 250 | 'adm_code', 'suspended_comment', |
---|
| 251 | 'date_of_birth', 'current_level', |
---|
[12150] | 252 | 'department', 'current_mode', |
---|
[13717] | 253 | 'entry_session', 'matric_number', 'sex', |
---|
| 254 | 'flash_notice') |
---|
[12121] | 255 | |
---|
| 256 | form_fields = [] |
---|
| 257 | |
---|
| 258 | @property |
---|
| 259 | def note(self): |
---|
| 260 | if self.context.physical_clearance_date: |
---|
| 261 | return """ |
---|
[12147] | 262 | <br /><br /><br /><br /><font size='12'> |
---|
| 263 | Dear %s, |
---|
| 264 | <br /><br /><br /> |
---|
[12264] | 265 | You are invited for your physical clearance on: |
---|
[12121] | 266 | <br /><br /> |
---|
[12264] | 267 | <strong>%s</strong>. |
---|
| 268 | <br /><br /> |
---|
[12265] | 269 | Please bring along this letter of invitation to the University Main Auditorium |
---|
[12147] | 270 | <br /><br /> |
---|
[12263] | 271 | on your clearance date. |
---|
[12147] | 272 | <br /><br /><br /> |
---|
[12263] | 273 | Signed, |
---|
[12147] | 274 | <br /><br /> |
---|
| 275 | The Registrar<br /> |
---|
[12121] | 276 | </font> |
---|
| 277 | |
---|
[12147] | 278 | """ % (self.context.display_fullname, self.context.physical_clearance_date) |
---|
[12121] | 279 | return |
---|
| 280 | |
---|
[12122] | 281 | |
---|
| 282 | def update(self): |
---|
| 283 | if self.context.student.state != REQUESTED \ |
---|
| 284 | or not self.context.student.physical_clearance_date: |
---|
| 285 | self.flash(_('Forbidden'), type="warning") |
---|
| 286 | self.redirect(self.url(self.context)) |
---|
| 287 | |
---|
[12121] | 288 | def render(self): |
---|
| 289 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 290 | self.request, self.omit_fields) |
---|
| 291 | students_utils = getUtility(IStudentsUtils) |
---|
| 292 | return students_utils.renderPDF( |
---|
| 293 | self, 'clearance_invitation_slip', |
---|
| 294 | self.context.student, studentview, |
---|
| 295 | omit_fields=self.omit_fields, |
---|
| 296 | note=self.note) |
---|
| 297 | |
---|
[13723] | 298 | class ExportExaminationScheduleSlip(UtilityView, grok.View): |
---|
| 299 | """Deliver a examination schedule slip. |
---|
| 300 | |
---|
[14689] | 301 | This form page is available only in Uniben and AAUE. |
---|
[13723] | 302 | """ |
---|
| 303 | grok.context(ICustomStudent) |
---|
| 304 | grok.name('examination_schedule_slip.pdf') |
---|
| 305 | grok.require('waeup.viewStudent') |
---|
| 306 | prefix = 'form' |
---|
| 307 | |
---|
| 308 | label = u'Examination Schedule Slip' |
---|
| 309 | |
---|
| 310 | omit_fields = ( |
---|
| 311 | 'suspended', 'phone', 'email', |
---|
| 312 | 'adm_code', 'suspended_comment', |
---|
| 313 | 'date_of_birth', 'current_level', |
---|
| 314 | 'current_mode', |
---|
| 315 | 'entry_session', |
---|
| 316 | 'flash_notice') |
---|
| 317 | |
---|
| 318 | form_fields = [] |
---|
| 319 | |
---|
| 320 | @property |
---|
| 321 | def note(self): |
---|
| 322 | return """ |
---|
| 323 | <br /><br /><br /><br /><font size='12'> |
---|
| 324 | Your examination date, time and venue is scheduled as follows: |
---|
| 325 | <br /><br /> |
---|
| 326 | <strong>%s</strong> |
---|
| 327 | </font> |
---|
| 328 | |
---|
| 329 | """ % self.context.flash_notice |
---|
| 330 | return |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | def update(self): |
---|
| 334 | if not self.context.flash_notice \ |
---|
| 335 | or not 'exam' in self.context.flash_notice.lower(): |
---|
| 336 | self.flash(_('Forbidden'), type="warning") |
---|
| 337 | self.redirect(self.url(self.context)) |
---|
| 338 | |
---|
| 339 | def render(self): |
---|
| 340 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 341 | self.request, self.omit_fields) |
---|
| 342 | students_utils = getUtility(IStudentsUtils) |
---|
| 343 | return students_utils.renderPDF( |
---|
| 344 | self, 'examination_schedule_slip', |
---|
| 345 | self.context.student, studentview, |
---|
| 346 | omit_fields=self.omit_fields, |
---|
| 347 | note=self.note) |
---|
| 348 | |
---|
[15371] | 349 | class SwitchLibraryAccessView(UtilityView, grok.View): |
---|
| 350 | """ Switch the library attribute |
---|
| 351 | """ |
---|
| 352 | grok.context(ICustomStudent) |
---|
| 353 | grok.name('switch_library_access') |
---|
| 354 | grok.require('waeup.switchLibraryAccess') |
---|
| 355 | |
---|
| 356 | def update(self): |
---|
| 357 | if self.context.library: |
---|
| 358 | self.context.library = False |
---|
| 359 | self.context.writeLogMessage(self, 'library access disabled') |
---|
| 360 | self.flash(_('Library access disabled')) |
---|
| 361 | else: |
---|
| 362 | self.context.library = True |
---|
| 363 | self.context.writeLogMessage(self, 'library access enabled') |
---|
| 364 | self.flash(_('Library access enabled')) |
---|
| 365 | self.redirect(self.url(self.context)) |
---|
| 366 | return |
---|
| 367 | |
---|
| 368 | def render(self): |
---|
| 369 | return |
---|
| 370 | |
---|
[15352] | 371 | class ExportJHLIdCard(UtilityView, grok.View): |
---|
[15371] | 372 | """Deliver an id card for the John Harris Library. |
---|
[15352] | 373 | """ |
---|
| 374 | grok.context(ICustomStudent) |
---|
| 375 | grok.name('jhl_idcard.pdf') |
---|
| 376 | grok.require('waeup.viewStudent') |
---|
| 377 | prefix = 'form' |
---|
| 378 | |
---|
[15403] | 379 | label = u"John Harris Library Clearance" |
---|
[15352] | 380 | |
---|
| 381 | omit_fields = ( |
---|
[15371] | 382 | 'suspended', 'email', 'phone', |
---|
[15352] | 383 | 'adm_code', 'suspended_comment', |
---|
[15371] | 384 | 'date_of_birth', |
---|
[15352] | 385 | 'current_mode', 'certificate', |
---|
| 386 | 'entry_session', |
---|
| 387 | 'flash_notice') |
---|
| 388 | |
---|
| 389 | form_fields = [] |
---|
| 390 | |
---|
| 391 | def _sigsInFooter(self): |
---|
[15371] | 392 | isStudent = getattr( |
---|
| 393 | self.request.principal, 'user_type', None) == 'student' |
---|
| 394 | if isStudent: |
---|
| 395 | return '' |
---|
[15352] | 396 | return (_("Date, Reader's Signature"), |
---|
| 397 | _("Date, Circulation Librarian's Signature"), |
---|
| 398 | ) |
---|
| 399 | |
---|
[15371] | 400 | def update(self): |
---|
| 401 | if not self.context.library: |
---|
| 402 | self.flash(_('Forbidden!'), type="danger") |
---|
| 403 | self.redirect(self.url(self.context)) |
---|
| 404 | return |
---|
| 405 | |
---|
[15352] | 406 | @property |
---|
| 407 | def note(self): |
---|
| 408 | return """ |
---|
| 409 | <br /><br /><br /><br /><font size='12'> |
---|
| 410 | This is to certify that the bearer whose photograph and other details appear |
---|
| 411 | overleaf is a registered user of <b>John Harris Library, University of Benin</b>. |
---|
| 412 | The card is not transferable. A replacement fee is charged for a loss, |
---|
| 413 | mutilation or otherwise. If found, please, return to John Harris Library, |
---|
| 414 | University of Benin, Benin City. |
---|
| 415 | </font> |
---|
| 416 | |
---|
| 417 | """ |
---|
| 418 | return |
---|
| 419 | |
---|
| 420 | def render(self): |
---|
| 421 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 422 | self.request, self.omit_fields) |
---|
| 423 | students_utils = getUtility(IStudentsUtils) |
---|
| 424 | return students_utils.renderPDF( |
---|
| 425 | self, 'jhl_idcard', |
---|
| 426 | self.context.student, studentview, |
---|
| 427 | omit_fields=self.omit_fields, |
---|
| 428 | sigs_in_footer=self._sigsInFooter(), |
---|
| 429 | note=self.note) |
---|
| 430 | |
---|
[14834] | 431 | class ExportJUPEBResultSlip(ExportExaminationScheduleSlip): |
---|
| 432 | """Deliver a JUPEB result slip. |
---|
| 433 | |
---|
| 434 | This form page is available only in Uniben. |
---|
| 435 | """ |
---|
| 436 | |
---|
| 437 | grok.name('jupeb_result_slip.pdf') |
---|
| 438 | label = u'JUPEB Result Slip' |
---|
| 439 | |
---|
| 440 | @property |
---|
| 441 | def note(self): |
---|
| 442 | return """ |
---|
| 443 | <br /><br /><br /><br /><font size='12'> |
---|
| 444 | <strong>%s</strong> |
---|
| 445 | </font> |
---|
| 446 | <br /><br /><br /><br /> |
---|
| 447 | <font size='8'> |
---|
| 448 | Key: A = 5, B = 4, C = 3, D = 2, E = 1, F = 0, X = Absent, Q = Cancelled |
---|
| 449 | </font> |
---|
| 450 | |
---|
| 451 | """ % self.context.flash_notice |
---|
| 452 | return |
---|
| 453 | |
---|
| 454 | def update(self): |
---|
[14902] | 455 | if not self.context.flash_notice or not self.context.is_jupeb \ |
---|
[14835] | 456 | or not 'results' in self.context.flash_notice.lower(): |
---|
[14834] | 457 | self.flash(_('Forbidden'), type="warning") |
---|
| 458 | self.redirect(self.url(self.context)) |
---|
| 459 | |
---|
[12856] | 460 | class CustomStudentPersonalDisplayFormPage( |
---|
| 461 | NigeriaStudentPersonalDisplayFormPage): |
---|
| 462 | """ Page to display student personal data |
---|
| 463 | """ |
---|
| 464 | |
---|
[17395] | 465 | form_fields = grok.AutoFields(ICustomStudentPersonal) + grok.AutoFields(ITiship) |
---|
[12856] | 466 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 467 | form_fields['next_kin_address'].custom_widget = BytesDisplayWidget |
---|
| 468 | form_fields[ |
---|
| 469 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 470 | |
---|
| 471 | class CustomStudentPersonalManageFormPage( |
---|
| 472 | NigeriaStudentPersonalManageFormPage): |
---|
| 473 | """ Page to manage personal data |
---|
| 474 | """ |
---|
| 475 | |
---|
[17395] | 476 | form_fields = grok.AutoFields(ICustomStudentPersonal) + grok.AutoFields(ITiship) |
---|
[12856] | 477 | form_fields['personal_updated'].for_display = True |
---|
| 478 | form_fields[ |
---|
| 479 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 480 | |
---|
[13085] | 481 | class CstomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage): |
---|
| 482 | """ Page to edit personal data |
---|
| 483 | """ |
---|
| 484 | |
---|
[17395] | 485 | @property |
---|
| 486 | def form_fields(self): |
---|
| 487 | form_fields = grok.AutoFields( |
---|
| 488 | ICustomStudentPersonalEdit).omit('personal_updated') + grok.AutoFields(ITiship) |
---|
| 489 | studycourse = self.context['studycourse'] |
---|
| 490 | certificate = getattr(studycourse,'certificate',None) |
---|
| 491 | current_level = studycourse.current_level |
---|
| 492 | end_level = certificate.end_level |
---|
| 493 | if not self.context.current_level >= end_level: |
---|
| 494 | form_fields = form_fields.omit('nysc') |
---|
| 495 | return form_fields |
---|
| 496 | |
---|
[9210] | 497 | class StudyCourseCOEditFormPage(KofaEditFormPage): |
---|
[9281] | 498 | """ Page to edit the student study course data by clearance officers. |
---|
[9210] | 499 | |
---|
| 500 | This form page is available only in Uniben. |
---|
| 501 | """ |
---|
| 502 | grok.context(ICustomStudentStudyCourse) |
---|
| 503 | grok.name('edit_level') |
---|
| 504 | grok.require('waeup.clearStudent') |
---|
| 505 | label = _('Edit current level') |
---|
| 506 | pnav = 4 |
---|
| 507 | form_fields = grok.AutoFields( |
---|
| 508 | ICustomStudentStudyCourse).select('current_level') |
---|
| 509 | |
---|
| 510 | def update(self): |
---|
| 511 | if not (self.context.is_current and |
---|
| 512 | self.context.student.state == REQUESTED): |
---|
| 513 | emit_lock_message(self) |
---|
| 514 | return |
---|
| 515 | super(StudyCourseCOEditFormPage, self).update() |
---|
| 516 | return |
---|
| 517 | |
---|
| 518 | @action(_('Save'), style='primary') |
---|
| 519 | def save(self, **data): |
---|
| 520 | try: |
---|
| 521 | msave(self, **data) |
---|
| 522 | except ConstraintNotSatisfied: |
---|
| 523 | # The selected level might not exist in certificate |
---|
| 524 | self.flash(_('Current level not available for certificate.')) |
---|
| 525 | return |
---|
[16440] | 526 | #notify(grok.ObjectModifiedEvent(self.context.__parent__)) |
---|
[9281] | 527 | return |
---|
| 528 | |
---|
| 529 | class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): |
---|
| 530 | """ Page to edit the student study level data by students. |
---|
| 531 | |
---|
| 532 | """ |
---|
[9686] | 533 | grok.template('studyleveleditpage') |
---|
[9281] | 534 | |
---|
[9686] | 535 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 536 | """ Page to display student study levels |
---|
| 537 | """ |
---|
| 538 | grok.template('studylevelpage') |
---|
| 539 | |
---|
[16427] | 540 | @property |
---|
| 541 | def view_scores_allowed(self): |
---|
| 542 | return checkPermission('waeup.manageStudent', self.context) |
---|
| 543 | |
---|
[13063] | 544 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 545 | ExportPDFCourseRegistrationSlip): |
---|
[9686] | 546 | """Deliver a PDF slip of the context. |
---|
| 547 | """ |
---|
| 548 | |
---|
[9921] | 549 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
---|
[15404] | 550 | 'level_verdict', 'gpa', 'level', 'transcript_remark') |
---|
[9921] | 551 | |
---|
[12855] | 552 | def update(self): |
---|
| 553 | if self.context.student.state != REGISTERED \ |
---|
| 554 | or self.context.student.current_level != self.context.level: |
---|
| 555 | self.flash(_('Forbidden'), type="warning") |
---|
| 556 | self.redirect(self.url(self.context)) |
---|
| 557 | |
---|
[10441] | 558 | @property |
---|
| 559 | def tabletitle(self): |
---|
| 560 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 561 | tabletitle = [] |
---|
| 562 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 563 | target_language=portal_language)) |
---|
| 564 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 565 | target_language=portal_language)) |
---|
| 566 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 567 | target_language=portal_language)) |
---|
| 568 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 569 | target_language=portal_language)) |
---|
| 570 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 571 | target_language=portal_language)) |
---|
| 572 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 573 | target_language=portal_language)) |
---|
| 574 | return tabletitle |
---|
| 575 | |
---|
[9686] | 576 | def render(self): |
---|
| 577 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 578 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 579 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 580 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 581 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 582 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
[9686] | 583 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 584 | self.request, self.omit_fields) |
---|
| 585 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 586 | |
---|
| 587 | tabledata = [] |
---|
| 588 | tableheader = [] |
---|
| 589 | for i in range(1,7): |
---|
| 590 | tabledata.append(sorted( |
---|
| 591 | [value for value in self.context.values() if value.semester == i], |
---|
| 592 | key=lambda value: str(value.semester) + value.code)) |
---|
| 593 | tableheader.append([(Code,'code', 2.5), |
---|
| 594 | (Title,'title', 5), |
---|
| 595 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 596 | (Cred, 'credits', 1.5), |
---|
| 597 | ]) |
---|
[9686] | 598 | return students_utils.renderPDF( |
---|
| 599 | self, 'course_registration_slip.pdf', |
---|
| 600 | self.context.student, studentview, |
---|
[10441] | 601 | tableheader=tableheader, |
---|
| 602 | tabledata=tabledata, |
---|
[10271] | 603 | omit_fields=self.omit_fields |
---|
[9908] | 604 | ) |
---|
[9848] | 605 | |
---|
[15401] | 606 | class ExportPDFCourseResultSlip(ExportPDFCourseRegistrationSlip): |
---|
[9848] | 607 | """Deliver a PDF slip of the context. |
---|
| 608 | """ |
---|
| 609 | |
---|
| 610 | grok.name('course_result_slip.pdf') |
---|
| 611 | |
---|
[15401] | 612 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 613 | |
---|
[9848] | 614 | @property |
---|
[10441] | 615 | def tabletitle(self): |
---|
| 616 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 617 | tabletitle = [] |
---|
| 618 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 619 | target_language=portal_language)) |
---|
| 620 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 621 | target_language=portal_language)) |
---|
| 622 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 623 | target_language=portal_language)) |
---|
| 624 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 625 | target_language=portal_language)) |
---|
| 626 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 627 | target_language=portal_language)) |
---|
| 628 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 629 | target_language=portal_language)) |
---|
| 630 | return tabletitle |
---|
| 631 | |
---|
| 632 | @property |
---|
[9848] | 633 | def label(self): |
---|
| 634 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 635 | lang = self.request.cookies.get('kofa.language', portal_language) |
---|
| 636 | level_title = translate(self.context.level_title, 'waeup.kofa', |
---|
| 637 | target_language=lang) |
---|
| 638 | return translate(_('Course Result Slip'), |
---|
| 639 | 'waeup.uniben', target_language=portal_language) \ |
---|
| 640 | + ' %s' % level_title |
---|
| 641 | |
---|
| 642 | def render(self): |
---|
| 643 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 644 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 645 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 646 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 647 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 648 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
| 649 | Grade = translate('Grade', 'waeup.kofa', target_language=portal_language) |
---|
[9848] | 650 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 651 | self.request, self.omit_fields) |
---|
| 652 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 653 | |
---|
| 654 | tabledata = [] |
---|
| 655 | tableheader = [] |
---|
| 656 | for i in range(1,7): |
---|
| 657 | tabledata.append(sorted( |
---|
| 658 | [value for value in self.context.values() if value.semester == i], |
---|
| 659 | key=lambda value: str(value.semester) + value.code)) |
---|
| 660 | tableheader.append([(Code,'code', 2.5), |
---|
| 661 | (Title,'title', 5), |
---|
| 662 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 663 | (Cred, 'credits', 1.5), |
---|
| 664 | (Grade, 'grade', 1.5), |
---|
| 665 | ]) |
---|
[9908] | 666 | return students_utils.renderPDF( |
---|
[15401] | 667 | self, 'course_result_slip.pdf', |
---|
[9908] | 668 | self.context.student, studentview, |
---|
[10441] | 669 | tableheader=tableheader, |
---|
| 670 | tabledata=tabledata, |
---|
[10271] | 671 | omit_fields=self.omit_fields |
---|
[9908] | 672 | ) |
---|
[9686] | 673 | |
---|
| 674 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
---|
| 675 | """ Page to display course tickets |
---|
| 676 | """ |
---|
[16509] | 677 | form_fields = grok.AutoFields(ICustomCourseTicket).omit('score') |
---|
[11069] | 678 | |
---|
[16509] | 679 | class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): |
---|
| 680 | """ Page to manage course tickets |
---|
| 681 | """ |
---|
| 682 | |
---|
| 683 | form_fields = grok.AutoFields(ICustomCourseTicket).omit('course_category') |
---|
| 684 | form_fields['title'].for_display = True |
---|
| 685 | form_fields['fcode'].for_display = True |
---|
| 686 | form_fields['dcode'].for_display = True |
---|
| 687 | form_fields['semester'].for_display = True |
---|
| 688 | form_fields['passmark'].for_display = True |
---|
| 689 | form_fields['credits'].for_display = True |
---|
| 690 | form_fields['mandatory'].for_display = False |
---|
| 691 | form_fields['automatic'].for_display = True |
---|
| 692 | form_fields['carry_over'].for_display = True |
---|
| 693 | form_fields['ticket_session'].for_display = True |
---|
| 694 | |
---|
[13063] | 695 | class CustomStudentActivateView(StudentActivateView): |
---|
[11069] | 696 | """ Activate student account |
---|
| 697 | """ |
---|
| 698 | |
---|
| 699 | def update(self): |
---|
| 700 | self.context.suspended = False |
---|
| 701 | self.context.writeLogMessage(self, 'account activated') |
---|
| 702 | history = IObjectHistory(self.context) |
---|
| 703 | history.addMessage('Student account activated', user='undisclosed') |
---|
| 704 | self.flash(_('Student account has been activated.')) |
---|
| 705 | self.redirect(self.url(self.context)) |
---|
| 706 | return |
---|
| 707 | |
---|
[13063] | 708 | class CustomStudentDeactivateView(StudentDeactivateView): |
---|
[11069] | 709 | """ Deactivate student account |
---|
| 710 | """ |
---|
| 711 | def update(self): |
---|
| 712 | self.context.suspended = True |
---|
| 713 | self.context.writeLogMessage(self, 'account deactivated') |
---|
| 714 | history = IObjectHistory(self.context) |
---|
| 715 | history.addMessage('Student account deactivated', user='undisclosed') |
---|
| 716 | self.flash(_('Student account has been deactivated.')) |
---|
| 717 | self.redirect(self.url(self.context)) |
---|
| 718 | return |
---|
[12845] | 719 | |
---|
[16906] | 720 | class CustomStudyCourseTranscriptPage(StudyCourseTranscriptPage): |
---|
| 721 | """ Page to display the student's transcript. |
---|
| 722 | """ |
---|
[17049] | 723 | # grok.require('waeup.viewStudent') |
---|
[16906] | 724 | |
---|
[13063] | 725 | class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip): |
---|
[12845] | 726 | """Deliver a PDF slip of the context. |
---|
| 727 | """ |
---|
[17049] | 728 | # grok.require('waeup.viewStudent') |
---|
[12845] | 729 | |
---|
[16171] | 730 | def _sigsInFooter(self): |
---|
| 731 | isStudent = getattr( |
---|
| 732 | self.request.principal, 'user_type', None) == 'student' |
---|
| 733 | if not isStudent and self.context.student.state in (TRANSVAL, TRANSREL): |
---|
| 734 | return (_('D. R. (Exams & Records)'),_('Current Dean of Faculty'),) |
---|
| 735 | return () |
---|
[12845] | 736 | |
---|
[14689] | 737 | #def _signatures(self): |
---|
| 738 | # return ([( |
---|
| 739 | # 'Current HD<br /> D. R. (Exams & Records)<br /> ' |
---|
| 740 | # 'For: Registrar')],) |
---|
[12845] | 741 | |
---|
| 742 | def render(self): |
---|
| 743 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 744 | Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language) |
---|
| 745 | Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) |
---|
| 746 | Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) |
---|
| 747 | Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language) |
---|
| 748 | #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) |
---|
| 749 | Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) |
---|
| 750 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 751 | self.request, self.omit_fields) |
---|
| 752 | students_utils = getUtility(IStudentsUtils) |
---|
| 753 | |
---|
| 754 | tableheader = [(Code,'code', 2.5), |
---|
| 755 | (Title,'title', 8.5), |
---|
| 756 | (Term, 'semester', 1.5), |
---|
| 757 | (Cred, 'credits', 1.5), |
---|
| 758 | #(Score, 'score', 1.5), |
---|
| 759 | (Grade, 'grade', 1.5), |
---|
| 760 | ] |
---|
| 761 | |
---|
[15164] | 762 | pdfstream = students_utils.renderPDFTranscript( |
---|
[12845] | 763 | self, 'transcript.pdf', |
---|
| 764 | self.context.student, studentview, |
---|
| 765 | omit_fields=self.omit_fields, |
---|
| 766 | tableheader=tableheader, |
---|
| 767 | signatures=self._signatures(), |
---|
| 768 | sigs_in_footer=self._sigsInFooter(), |
---|
[15164] | 769 | digital_sigs=self._digital_sigs(), |
---|
| 770 | save_file=self._save_file(), |
---|
[13297] | 771 | ) |
---|
[15164] | 772 | if not pdfstream: |
---|
| 773 | self.redirect(self.url(self.context.student)) |
---|
| 774 | return |
---|
| 775 | return pdfstream |
---|
[13297] | 776 | |
---|
| 777 | class CustomExportPDFBedTicketSlip(NigeriaExportPDFBedTicketSlip): |
---|
| 778 | """Deliver a PDF slip of the context. |
---|
| 779 | """ |
---|
[13317] | 780 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
[13717] | 781 | 'phone', 'adm_code', 'email', 'date_of_birth', 'flash_notice') |
---|
[13297] | 782 | |
---|
[13719] | 783 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 784 | """ Page to manage the student payments. This manage form page is for |
---|
| 785 | both students and students officers. Uniben does not allow students |
---|
| 786 | to remove any payment ticket. |
---|
| 787 | """ |
---|
| 788 | @property |
---|
| 789 | def manage_payments_allowed(self): |
---|
[13723] | 790 | return checkPermission('waeup.manageStudent', self.context) |
---|
[15267] | 791 | |
---|
[15975] | 792 | class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): |
---|
| 793 | """ Page to view bed tickets. |
---|
| 794 | """ |
---|
| 795 | with_hostel_selection = True |
---|
| 796 | |
---|
[15267] | 797 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
| 798 | """ Page to manage bed tickets. |
---|
| 799 | This manage form page is for both students and students officers. |
---|
| 800 | """ |
---|
[15352] | 801 | with_hostel_selection = True |
---|
| 802 | |
---|
| 803 | class CustomStudentBaseEditFormPage(StudentBaseEditFormPage): |
---|
| 804 | """ View to edit student base data |
---|
| 805 | """ |
---|
| 806 | form_fields = grok.AutoFields(ICustomStudentBase).select( |
---|
| 807 | 'email', 'phone') |
---|
| 808 | form_fields['email'].field.required = True |
---|
[16361] | 809 | |
---|
| 810 | class CustomStudentFilesUploadPage(NigeriaStudentFilesUploadPage): |
---|
| 811 | """ View to upload passport picture. |
---|
| 812 | """ |
---|
| 813 | |
---|
| 814 | def update(self): |
---|
[17142] | 815 | # Postgrad students should allowed to change their picture whenever they want. |
---|
| 816 | if self.context.is_postgrad: |
---|
[17125] | 817 | return |
---|
[17060] | 818 | if self.context.is_jupeb: |
---|
[16362] | 819 | emit_lock_message(self) |
---|
[17060] | 820 | return |
---|
[16361] | 821 | super(StudentFilesUploadPage, self).update() |
---|
[16382] | 822 | return |
---|
| 823 | |
---|
[16385] | 824 | |
---|
| 825 | |
---|
| 826 | from zope.schema.vocabulary import SimpleVocabulary |
---|
| 827 | from zope.formlib.itemswidgets import RadioWidget |
---|
| 828 | from zope.formlib.itemswidgets import SelectWidget, DropdownWidget |
---|
| 829 | |
---|
| 830 | def CustomBooleanRadioWidget(field, request, true=_('yes'), false=_('no')): |
---|
| 831 | vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) ) |
---|
| 832 | widget = RadioWidget(field, vocabulary, request) |
---|
| 833 | widget.required = False |
---|
| 834 | return widget |
---|
| 835 | |
---|
[16382] | 836 | class StudentMedicalHistoryEditFormPage(KofaEditFormPage): |
---|
[16383] | 837 | """ Page to edit medical data |
---|
[16382] | 838 | """ |
---|
| 839 | grok.context(ICustomStudent) |
---|
| 840 | grok.name('edit_medical') |
---|
| 841 | grok.require('waeup.handleStudent') |
---|
[16385] | 842 | label = _('Medical Questionnaire') |
---|
[16382] | 843 | pnav = 4 |
---|
| 844 | |
---|
[16386] | 845 | def _medicalQuestPaymentMade(self, student, session): |
---|
| 846 | if len(student['payments']): |
---|
| 847 | for ticket in student['payments'].values(): |
---|
| 848 | if ticket.p_state == 'paid' and \ |
---|
| 849 | ticket.p_category == 'medical_quest' and \ |
---|
| 850 | ticket.p_session == session: |
---|
| 851 | return True |
---|
| 852 | return False |
---|
| 853 | |
---|
| 854 | def update(self): |
---|
| 855 | if not self._medicalQuestPaymentMade( |
---|
| 856 | self.context, self.context.current_session): |
---|
| 857 | self.flash('Please pay medical questionnaire payment first.', |
---|
| 858 | type="warning") |
---|
| 859 | self.redirect(self.url(self.context)) |
---|
| 860 | return |
---|
| 861 | return super(StudentMedicalHistoryEditFormPage, self).update() |
---|
| 862 | |
---|
[16382] | 863 | @property |
---|
[16385] | 864 | def form_fields(self): |
---|
[17395] | 865 | form_fields = grok.AutoFields(IMedicalHistory) + grok.AutoFields(ITiship) |
---|
[16385] | 866 | form_fields['medical_updated'].for_display = True |
---|
| 867 | for field in ('fever', 'headaches', 'catarrh', 'cough', 'sore_throat', |
---|
| 868 | 'breathing', 'sneezing', 'weakness', 'body_pains', |
---|
| 869 | 'smell', 'taste', 'asthma', 'hypertension', 'diabetes', |
---|
| 870 | 'obesity', 'lagos_abuja', 'outside', 'company_suspected', |
---|
| 871 | 'company_confirmed', 'positive', 'negative', |
---|
| 872 | 'vaccination'): |
---|
| 873 | form_fields[field].custom_widget = CustomBooleanRadioWidget |
---|
| 874 | return form_fields |
---|
| 875 | |
---|
| 876 | @property |
---|
[16382] | 877 | def separators(self): |
---|
| 878 | return getUtility(IStudentsUtils).SEPARATORS_DICT |
---|
| 879 | |
---|
| 880 | @action(_('Save/Confirm'), style='primary') |
---|
| 881 | def save(self, **data): |
---|
| 882 | msave(self, **data) |
---|
| 883 | self.context.medical_updated = datetime.utcnow() |
---|
| 884 | return |
---|
| 885 | |
---|
[16383] | 886 | class StudentMedicalHistoryManageFormPage(StudentMedicalHistoryEditFormPage): |
---|
| 887 | """ Page to manage medical data |
---|
| 888 | """ |
---|
| 889 | grok.name('manage_medical') |
---|
| 890 | grok.require('waeup.manageStudent') |
---|
[16385] | 891 | label = _('Manage medical questionnaire data') |
---|
[16383] | 892 | |
---|
[16405] | 893 | def update(self): |
---|
| 894 | return super(StudentMedicalHistoryEditFormPage, self).update() |
---|
| 895 | |
---|
[17255] | 896 | |
---|
[16382] | 897 | class ExportPDFMedicalHistorySlip(grok.View): |
---|
| 898 | """Deliver a PDF slip of the context. |
---|
| 899 | """ |
---|
| 900 | grok.context(ICustomStudent) |
---|
[16385] | 901 | grok.name('medical_questionnaire_slip.pdf') |
---|
[16382] | 902 | grok.require('waeup.viewStudent') |
---|
| 903 | prefix = 'form' |
---|
| 904 | form_fields = grok.AutoFields(IMedicalHistory) |
---|
| 905 | |
---|
| 906 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
| 907 | 'adm_code', 'date_of_birth', |
---|
| 908 | 'flash_notice', 'current_mode', 'entry_mode', |
---|
[17255] | 909 | 'entry_session', 'parents_email', |
---|
[16382] | 910 | 'current_level', 'reg_number', 'sex', |
---|
| 911 | 'certificate') |
---|
| 912 | |
---|
| 913 | @property |
---|
| 914 | def title(self): |
---|
| 915 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[16385] | 916 | return translate(_('Medical Questionnaire'), 'waeup.kofa', |
---|
[16382] | 917 | target_language=portal_language) |
---|
| 918 | |
---|
| 919 | @property |
---|
| 920 | def label(self): |
---|
| 921 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[16385] | 922 | return translate(_('Medical Questionnaire Slip of'), |
---|
[16382] | 923 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 924 | + ' %s' % self.context.display_fullname |
---|
| 925 | |
---|
| 926 | def render(self): |
---|
| 927 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 928 | self.request, self.omit_fields) |
---|
| 929 | students_utils = getUtility(IStudentsUtils) |
---|
| 930 | return students_utils.renderPDF( |
---|
[16385] | 931 | self, 'medical_questionnaire_slip.pdf', |
---|
[16382] | 932 | self.context.student, studentview, |
---|
[16782] | 933 | omit_fields=self.omit_fields,) |
---|
| 934 | |
---|
[17255] | 935 | class ExportPDFTishipSlip(grok.View): |
---|
| 936 | """Deliver a PDF slip of the context. |
---|
| 937 | """ |
---|
| 938 | grok.context(ICustomStudent) |
---|
| 939 | grok.name('tiship_slip.pdf') |
---|
| 940 | grok.require('waeup.viewStudent') |
---|
| 941 | prefix = 'form' |
---|
[17395] | 942 | form_fields = grok.AutoFields(ITiship) |
---|
[17255] | 943 | title = '' |
---|
| 944 | |
---|
| 945 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
| 946 | 'adm_code', |
---|
| 947 | 'flash_notice', 'current_mode', 'entry_mode', |
---|
| 948 | 'parents_email', |
---|
| 949 | ) |
---|
| 950 | |
---|
| 951 | @property |
---|
| 952 | def label(self): |
---|
| 953 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 954 | return translate(_('TISHIP Registration Slip of'), |
---|
| 955 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 956 | + ' %s' % self.context.display_fullname |
---|
| 957 | |
---|
| 958 | |
---|
| 959 | def _sigsInFooter(self): |
---|
| 960 | return (_('Year of Graduation'), |
---|
| 961 | _('Signature'), |
---|
| 962 | _('Date'), |
---|
| 963 | ) |
---|
| 964 | |
---|
| 965 | def render(self): |
---|
| 966 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 967 | self.request, self.omit_fields) |
---|
| 968 | students_utils = getUtility(IStudentsUtils) |
---|
| 969 | return students_utils.renderPDF( |
---|
| 970 | self, 'tiship_slip.pdf', |
---|
| 971 | self.context.student, studentview, |
---|
| 972 | sigs_in_footer=self._sigsInFooter(), |
---|
| 973 | omit_fields=self.omit_fields,) |
---|
| 974 | |
---|
[16782] | 975 | class PlagTestInfoPage(KofaPage): |
---|
| 976 | "Landing page after plagiation test payment" |
---|
| 977 | grok.context(ICustomStudentOnlinePayment) |
---|
| 978 | grok.name('plagtestinfo') |
---|
[16797] | 979 | grok.require('waeup.viewStudent') |
---|
[16782] | 980 | |
---|
| 981 | def update(self): |
---|
[16795] | 982 | if self.context.p_state != 'paid' \ |
---|
[16793] | 983 | or self.context.p_category != 'plag_test': |
---|
[16782] | 984 | self.flash(_('Forbidden'), type="danger") |
---|
| 985 | self.redirect(self.url(self.context)) |
---|
[16793] | 986 | return super(PlagTestInfoPage, self).update() |
---|
| 987 | |
---|
| 988 | @property |
---|
| 989 | def facdep(self): |
---|
| 990 | facdepkey = "%s-%s" % (self.context.student.faccode, |
---|
| 991 | self.context.student.depcode) |
---|
[17362] | 992 | return DEPLINKS[facdepkey] |
---|
| 993 | |
---|
| 994 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
| 995 | """Deliver a PDF Admission slip. |
---|
| 996 | """ |
---|
| 997 | |
---|
| 998 | @property |
---|
| 999 | def post_text_pt(self): |
---|
| 1000 | datelist = self.context.history.messages[0].split()[0].split('-') |
---|
| 1001 | creation_date = u'%s/%s/%s' % (datelist[2], datelist[1], datelist[0]) |
---|
| 1002 | return ( |
---|
| 1003 | 'Your Kofa student record was created on %s. <br/><br/>' |
---|
| 1004 | 'Please Note: This admission for ' |
---|
| 1005 | 'Undergraduate Part-Time and Undergraduate Sandwich is incomplete ' |
---|
| 1006 | 'until you have successfully applied on the <b>JAMB CAPS PORTAL</b>. ' |
---|
| 1007 | 'Ignore this if you have completed your own <b>pre-admission</b> ' |
---|
| 1008 | 'activities on the JAMB website.' % creation_date) |
---|
| 1009 | |
---|
| 1010 | def render(self): |
---|
| 1011 | students_utils = getUtility(IStudentsUtils) |
---|
| 1012 | letterhead_path = os.path.join( |
---|
| 1013 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
| 1014 | if not os.path.exists(letterhead_path): |
---|
| 1015 | letterhead_path = None |
---|
| 1016 | if self.context.current_mode in ('ug_pt', 'ug_sw'): |
---|
| 1017 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 1018 | self.context.student, omit_fields=self.omit_fields, |
---|
| 1019 | letterhead_path=letterhead_path, post_text=self.post_text_pt) |
---|
| 1020 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 1021 | self.context.student, omit_fields=self.omit_fields, |
---|
| 1022 | letterhead_path=letterhead_path, post_text=None) |
---|