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