[8911] | 1 | ## $Id: browser.py 15267 2018-12-13 07:16:11Z 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 |
---|
| 19 | from zope.i18n import translate |
---|
[13719] | 20 | from zope.security import checkPermission |
---|
[9210] | 21 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
[12856] | 22 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[9380] | 23 | from zope.component import getUtility |
---|
[9281] | 24 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[11069] | 25 | from waeup.kofa.interfaces import ( |
---|
| 26 | REQUESTED, IExtFileStore, IKofaUtils, IObjectHistory) |
---|
[8911] | 27 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[12121] | 28 | from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView |
---|
[9205] | 29 | from waeup.kofa.students.browser import ( |
---|
[9686] | 30 | StudyLevelEditFormPage, StudyLevelDisplayFormPage, |
---|
[13063] | 31 | StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, |
---|
[10025] | 32 | CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, |
---|
[11069] | 33 | msave, emit_lock_message, |
---|
[13063] | 34 | StudentActivateView, StudentDeactivateView, |
---|
[13719] | 35 | ExportPDFTranscriptSlip, |
---|
| 36 | PaymentsManageFormPage) |
---|
[12845] | 37 | from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID, |
---|
| 38 | CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, |
---|
[15164] | 39 | GRADUATED, FORBIDDEN_POSTGRAD_TRANS) |
---|
[9686] | 40 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
---|
[9251] | 41 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
[8911] | 42 | from kofacustom.nigeria.students.browser import ( |
---|
| 43 | NigeriaOnlinePaymentDisplayFormPage, |
---|
[9251] | 44 | NigeriaStudentBaseManageFormPage, |
---|
[9380] | 45 | NigeriaStudentClearanceEditFormPage, |
---|
[8911] | 46 | NigeriaOnlinePaymentAddFormPage, |
---|
[13063] | 47 | NigeriaExportPDFPaymentSlip, |
---|
| 48 | NigeriaExportPDFClearanceSlip, |
---|
[13297] | 49 | NigeriaExportPDFBedTicketSlip, |
---|
[12856] | 50 | NigeriaStudentPersonalDisplayFormPage, |
---|
[13085] | 51 | NigeriaStudentPersonalManageFormPage, |
---|
[15267] | 52 | NigeriaStudentPersonalEditFormPage, |
---|
| 53 | NigeriaAccommodationManageFormPage |
---|
[9281] | 54 | ) |
---|
[8911] | 55 | |
---|
[9210] | 56 | from waeup.uniben.students.interfaces import ( |
---|
[12121] | 57 | ICustomStudent, |
---|
[12856] | 58 | ICustomStudentOnlinePayment, |
---|
| 59 | ICustomStudentStudyCourse, |
---|
[11552] | 60 | ICustomStudentStudyLevel, |
---|
| 61 | ICustomUGStudentClearance, |
---|
[12856] | 62 | ICustomPGStudentClearance, |
---|
[13085] | 63 | ICustomStudentPersonal, |
---|
| 64 | ICustomStudentPersonalEdit) |
---|
[9210] | 65 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8911] | 66 | |
---|
| 67 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 68 | """ Page to view an online payment ticket |
---|
| 69 | """ |
---|
| 70 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 71 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9993] | 72 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 73 | form_fields[ |
---|
| 74 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 75 | form_fields[ |
---|
| 76 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 77 | |
---|
[9380] | 78 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 79 | """ View to edit student clearance data by student |
---|
| 80 | """ |
---|
| 81 | |
---|
[11552] | 82 | @property |
---|
| 83 | def form_fields(self): |
---|
| 84 | if self.context.is_postgrad: |
---|
| 85 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( |
---|
[12391] | 86 | 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment', |
---|
| 87 | 'physical_clearance_date') |
---|
[11552] | 88 | else: |
---|
| 89 | form_fields = grok.AutoFields(ICustomUGStudentClearance).omit( |
---|
[12391] | 90 | 'clearance_locked', 'clr_code', 'officer_comment', |
---|
| 91 | 'physical_clearance_date') |
---|
[11552] | 92 | form_fields['date_of_birth'].for_display = True |
---|
| 93 | form_fields['nationality'].for_display = True |
---|
| 94 | form_fields['lga'].for_display = True |
---|
| 95 | return form_fields |
---|
| 96 | |
---|
[9380] | 97 | def dataNotComplete(self): |
---|
| 98 | store = getUtility(IExtFileStore) |
---|
| 99 | if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'): |
---|
| 100 | return _('No birth certificate uploaded.') |
---|
| 101 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
| 102 | return _('No guarantor/referee letter uploaded.') |
---|
| 103 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
| 104 | return _('No acceptance letter uploaded.') |
---|
| 105 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
| 106 | return _('No first sitting result uploaded.') |
---|
[9395] | 107 | #if not store.getFileByContext(self.context, attr=u'scd_sit_scan.jpg'): |
---|
| 108 | # return _('No second sitting result uploaded.') |
---|
[9380] | 109 | if not store.getFileByContext(self.context, attr=u'secr_cults.jpg'): |
---|
[9848] | 110 | return _('No affidavit of non-membership of secret cults uploaded.') |
---|
[9380] | 111 | return False |
---|
| 112 | |
---|
[8911] | 113 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 114 | """ Page to add an online payment ticket |
---|
| 115 | """ |
---|
| 116 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
| 117 | 'p_category') |
---|
| 118 | |
---|
[13063] | 119 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 120 | """Deliver a PDF slip of the context. |
---|
| 121 | """ |
---|
| 122 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 123 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9993] | 124 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 125 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9205] | 126 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 127 | |
---|
| 128 | |
---|
[13063] | 129 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[9551] | 130 | """Deliver a PDF slip of the context. |
---|
| 131 | """ |
---|
| 132 | |
---|
[13303] | 133 | @property |
---|
| 134 | def omit_fields(self): |
---|
| 135 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
[13717] | 136 | 'phone', 'adm_code', 'email', 'date_of_birth', |
---|
| 137 | 'flash_notice') |
---|
[14902] | 138 | if self.context.is_jupeb: |
---|
[13303] | 139 | omit_fields += ('faculty', 'department') |
---|
| 140 | return omit_fields |
---|
[11537] | 141 | |
---|
[13299] | 142 | @property |
---|
| 143 | def label(self): |
---|
| 144 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13300] | 145 | line0 = '' |
---|
[14902] | 146 | if self.context.is_jupeb: |
---|
[13335] | 147 | line0 = 'Joint Universities Preliminary Examinations Board (JUPEB)\n' |
---|
[13300] | 148 | line1 = translate(_('Clearance Slip of'), |
---|
[13299] | 149 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 150 | + ' %s' % self.context.display_fullname |
---|
[13335] | 151 | return '%s%s' % (line0, line1) |
---|
[13299] | 152 | |
---|
[12846] | 153 | def _sigsInFooter(self): |
---|
[12845] | 154 | isStudent = getattr( |
---|
| 155 | self.request.principal, 'user_type', None) == 'student' |
---|
[12852] | 156 | if not isStudent and self.context.state in (CLEARED, RETURNING): |
---|
[12846] | 157 | return (_('Date, Student Signature'), |
---|
| 158 | _('Date, Clearance Officer Signature'), |
---|
| 159 | ) |
---|
| 160 | return () |
---|
[12845] | 161 | |
---|
[9551] | 162 | def render(self): |
---|
| 163 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 164 | self.request, self.omit_fields) |
---|
| 165 | students_utils = getUtility(IStudentsUtils) |
---|
| 166 | return students_utils.renderPDF( |
---|
| 167 | self, 'clearance_slip.pdf', |
---|
| 168 | self.context.student, studentview, signatures=self._signatures(), |
---|
[10271] | 169 | sigs_in_footer=self._sigsInFooter(), show_scans=False, |
---|
| 170 | omit_fields=self.omit_fields) |
---|
[9551] | 171 | |
---|
[12121] | 172 | |
---|
[13063] | 173 | class ExportClearanceInvitationSlip(UtilityView, grok.View): |
---|
[12121] | 174 | """Deliver an invitation letter to physical clearance. |
---|
| 175 | |
---|
| 176 | This form page is available only in Uniben. |
---|
| 177 | """ |
---|
| 178 | grok.context(ICustomStudent) |
---|
| 179 | grok.name('clearance_invitation_slip.pdf') |
---|
| 180 | grok.require('waeup.viewStudent') |
---|
| 181 | prefix = 'form' |
---|
| 182 | |
---|
[12263] | 183 | label = u'Invitation Letter for Physical Clearance' |
---|
[12121] | 184 | |
---|
| 185 | omit_fields = ( |
---|
| 186 | 'suspended', 'phone', 'email', |
---|
| 187 | 'adm_code', 'suspended_comment', |
---|
| 188 | 'date_of_birth', 'current_level', |
---|
[12150] | 189 | 'department', 'current_mode', |
---|
[13717] | 190 | 'entry_session', 'matric_number', 'sex', |
---|
| 191 | 'flash_notice') |
---|
[12121] | 192 | |
---|
| 193 | form_fields = [] |
---|
| 194 | |
---|
| 195 | @property |
---|
| 196 | def note(self): |
---|
| 197 | if self.context.physical_clearance_date: |
---|
| 198 | return """ |
---|
[12147] | 199 | <br /><br /><br /><br /><font size='12'> |
---|
| 200 | Dear %s, |
---|
| 201 | <br /><br /><br /> |
---|
[12264] | 202 | You are invited for your physical clearance on: |
---|
[12121] | 203 | <br /><br /> |
---|
[12264] | 204 | <strong>%s</strong>. |
---|
| 205 | <br /><br /> |
---|
[12265] | 206 | Please bring along this letter of invitation to the University Main Auditorium |
---|
[12147] | 207 | <br /><br /> |
---|
[12263] | 208 | on your clearance date. |
---|
[12147] | 209 | <br /><br /><br /> |
---|
[12263] | 210 | Signed, |
---|
[12147] | 211 | <br /><br /> |
---|
| 212 | The Registrar<br /> |
---|
[12121] | 213 | </font> |
---|
| 214 | |
---|
[12147] | 215 | """ % (self.context.display_fullname, self.context.physical_clearance_date) |
---|
[12121] | 216 | return |
---|
| 217 | |
---|
[12122] | 218 | |
---|
| 219 | def update(self): |
---|
| 220 | if self.context.student.state != REQUESTED \ |
---|
| 221 | or not self.context.student.physical_clearance_date: |
---|
| 222 | self.flash(_('Forbidden'), type="warning") |
---|
| 223 | self.redirect(self.url(self.context)) |
---|
| 224 | |
---|
[12121] | 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_invitation_slip', |
---|
| 231 | self.context.student, studentview, |
---|
| 232 | omit_fields=self.omit_fields, |
---|
| 233 | note=self.note) |
---|
| 234 | |
---|
[13723] | 235 | class ExportExaminationScheduleSlip(UtilityView, grok.View): |
---|
| 236 | """Deliver a examination schedule slip. |
---|
| 237 | |
---|
[14689] | 238 | This form page is available only in Uniben and AAUE. |
---|
[13723] | 239 | """ |
---|
| 240 | grok.context(ICustomStudent) |
---|
| 241 | grok.name('examination_schedule_slip.pdf') |
---|
| 242 | grok.require('waeup.viewStudent') |
---|
| 243 | prefix = 'form' |
---|
| 244 | |
---|
| 245 | label = u'Examination Schedule Slip' |
---|
| 246 | |
---|
| 247 | omit_fields = ( |
---|
| 248 | 'suspended', 'phone', 'email', |
---|
| 249 | 'adm_code', 'suspended_comment', |
---|
| 250 | 'date_of_birth', 'current_level', |
---|
| 251 | 'current_mode', |
---|
| 252 | 'entry_session', |
---|
| 253 | 'flash_notice') |
---|
| 254 | |
---|
| 255 | form_fields = [] |
---|
| 256 | |
---|
| 257 | @property |
---|
| 258 | def note(self): |
---|
| 259 | return """ |
---|
| 260 | <br /><br /><br /><br /><font size='12'> |
---|
| 261 | Your examination date, time and venue is scheduled as follows: |
---|
| 262 | <br /><br /> |
---|
| 263 | <strong>%s</strong> |
---|
| 264 | </font> |
---|
| 265 | |
---|
| 266 | """ % self.context.flash_notice |
---|
| 267 | return |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | def update(self): |
---|
| 271 | if not self.context.flash_notice \ |
---|
| 272 | or not 'exam' in self.context.flash_notice.lower(): |
---|
| 273 | self.flash(_('Forbidden'), type="warning") |
---|
| 274 | self.redirect(self.url(self.context)) |
---|
| 275 | |
---|
| 276 | def render(self): |
---|
| 277 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 278 | self.request, self.omit_fields) |
---|
| 279 | students_utils = getUtility(IStudentsUtils) |
---|
| 280 | return students_utils.renderPDF( |
---|
| 281 | self, 'examination_schedule_slip', |
---|
| 282 | self.context.student, studentview, |
---|
| 283 | omit_fields=self.omit_fields, |
---|
| 284 | note=self.note) |
---|
| 285 | |
---|
[14834] | 286 | class ExportJUPEBResultSlip(ExportExaminationScheduleSlip): |
---|
| 287 | """Deliver a JUPEB result slip. |
---|
| 288 | |
---|
| 289 | This form page is available only in Uniben. |
---|
| 290 | """ |
---|
| 291 | |
---|
| 292 | grok.name('jupeb_result_slip.pdf') |
---|
| 293 | label = u'JUPEB Result Slip' |
---|
| 294 | |
---|
| 295 | @property |
---|
| 296 | def note(self): |
---|
| 297 | return """ |
---|
| 298 | <br /><br /><br /><br /><font size='12'> |
---|
| 299 | <strong>%s</strong> |
---|
| 300 | </font> |
---|
| 301 | <br /><br /><br /><br /> |
---|
| 302 | <font size='8'> |
---|
| 303 | Key: A = 5, B = 4, C = 3, D = 2, E = 1, F = 0, X = Absent, Q = Cancelled |
---|
| 304 | </font> |
---|
| 305 | |
---|
| 306 | """ % self.context.flash_notice |
---|
| 307 | return |
---|
| 308 | |
---|
| 309 | def update(self): |
---|
[14902] | 310 | if not self.context.flash_notice or not self.context.is_jupeb \ |
---|
[14835] | 311 | or not 'results' in self.context.flash_notice.lower(): |
---|
[14834] | 312 | self.flash(_('Forbidden'), type="warning") |
---|
| 313 | self.redirect(self.url(self.context)) |
---|
| 314 | |
---|
[12856] | 315 | class CustomStudentPersonalDisplayFormPage( |
---|
| 316 | NigeriaStudentPersonalDisplayFormPage): |
---|
| 317 | """ Page to display student personal data |
---|
| 318 | """ |
---|
| 319 | |
---|
| 320 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 321 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 322 | form_fields['next_kin_address'].custom_widget = BytesDisplayWidget |
---|
| 323 | form_fields[ |
---|
| 324 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 325 | |
---|
| 326 | class CustomStudentPersonalManageFormPage( |
---|
| 327 | NigeriaStudentPersonalManageFormPage): |
---|
| 328 | """ Page to manage personal data |
---|
| 329 | """ |
---|
| 330 | |
---|
| 331 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 332 | form_fields['personal_updated'].for_display = True |
---|
| 333 | form_fields[ |
---|
| 334 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 335 | |
---|
[13085] | 336 | class CstomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage): |
---|
| 337 | """ Page to edit personal data |
---|
| 338 | """ |
---|
| 339 | form_fields = grok.AutoFields( |
---|
| 340 | ICustomStudentPersonalEdit).omit('personal_updated') |
---|
| 341 | |
---|
[9210] | 342 | class StudyCourseCOEditFormPage(KofaEditFormPage): |
---|
[9281] | 343 | """ Page to edit the student study course data by clearance officers. |
---|
[9210] | 344 | |
---|
| 345 | This form page is available only in Uniben. |
---|
| 346 | """ |
---|
| 347 | grok.context(ICustomStudentStudyCourse) |
---|
| 348 | grok.name('edit_level') |
---|
| 349 | grok.require('waeup.clearStudent') |
---|
| 350 | label = _('Edit current level') |
---|
| 351 | pnav = 4 |
---|
| 352 | form_fields = grok.AutoFields( |
---|
| 353 | ICustomStudentStudyCourse).select('current_level') |
---|
| 354 | |
---|
| 355 | def update(self): |
---|
| 356 | if not (self.context.is_current and |
---|
| 357 | self.context.student.state == REQUESTED): |
---|
| 358 | emit_lock_message(self) |
---|
| 359 | return |
---|
| 360 | super(StudyCourseCOEditFormPage, self).update() |
---|
| 361 | return |
---|
| 362 | |
---|
| 363 | @action(_('Save'), style='primary') |
---|
| 364 | def save(self, **data): |
---|
| 365 | try: |
---|
| 366 | msave(self, **data) |
---|
| 367 | except ConstraintNotSatisfied: |
---|
| 368 | # The selected level might not exist in certificate |
---|
| 369 | self.flash(_('Current level not available for certificate.')) |
---|
| 370 | return |
---|
| 371 | #notify(grok.ObjectModifiedEvent(self.context.__parent__)) |
---|
[9281] | 372 | return |
---|
| 373 | |
---|
| 374 | class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): |
---|
| 375 | """ Page to edit the student study level data by students. |
---|
| 376 | |
---|
| 377 | """ |
---|
[9686] | 378 | grok.template('studyleveleditpage') |
---|
[9281] | 379 | |
---|
[9686] | 380 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 381 | """ Page to display student study levels |
---|
| 382 | """ |
---|
| 383 | grok.template('studylevelpage') |
---|
| 384 | |
---|
[13063] | 385 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 386 | ExportPDFCourseRegistrationSlip): |
---|
[9686] | 387 | """Deliver a PDF slip of the context. |
---|
| 388 | """ |
---|
| 389 | |
---|
[9921] | 390 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
---|
[12879] | 391 | 'level_verdict', 'gpa', 'level') |
---|
[9921] | 392 | |
---|
[12855] | 393 | def update(self): |
---|
| 394 | if self.context.student.state != REGISTERED \ |
---|
| 395 | or self.context.student.current_level != self.context.level: |
---|
| 396 | self.flash(_('Forbidden'), type="warning") |
---|
| 397 | self.redirect(self.url(self.context)) |
---|
| 398 | |
---|
[10441] | 399 | @property |
---|
| 400 | def tabletitle(self): |
---|
| 401 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 402 | tabletitle = [] |
---|
| 403 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 404 | target_language=portal_language)) |
---|
| 405 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 406 | target_language=portal_language)) |
---|
| 407 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 408 | target_language=portal_language)) |
---|
| 409 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 410 | target_language=portal_language)) |
---|
| 411 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 412 | target_language=portal_language)) |
---|
| 413 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 414 | target_language=portal_language)) |
---|
| 415 | return tabletitle |
---|
| 416 | |
---|
[9686] | 417 | def render(self): |
---|
| 418 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 419 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 420 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 421 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 422 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 423 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
[9686] | 424 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 425 | self.request, self.omit_fields) |
---|
| 426 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 427 | |
---|
| 428 | tabledata = [] |
---|
| 429 | tableheader = [] |
---|
| 430 | for i in range(1,7): |
---|
| 431 | tabledata.append(sorted( |
---|
| 432 | [value for value in self.context.values() if value.semester == i], |
---|
| 433 | key=lambda value: str(value.semester) + value.code)) |
---|
| 434 | tableheader.append([(Code,'code', 2.5), |
---|
| 435 | (Title,'title', 5), |
---|
| 436 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 437 | (Cred, 'credits', 1.5), |
---|
| 438 | ]) |
---|
[9686] | 439 | return students_utils.renderPDF( |
---|
| 440 | self, 'course_registration_slip.pdf', |
---|
| 441 | self.context.student, studentview, |
---|
[10441] | 442 | tableheader=tableheader, |
---|
| 443 | tabledata=tabledata, |
---|
[10271] | 444 | omit_fields=self.omit_fields |
---|
[9908] | 445 | ) |
---|
[9848] | 446 | |
---|
[13063] | 447 | class UnibenExportPDFCourseResultSlip(ExportPDFCourseRegistrationSlip): |
---|
[9848] | 448 | """Deliver a PDF slip of the context. |
---|
| 449 | """ |
---|
| 450 | |
---|
| 451 | grok.name('course_result_slip.pdf') |
---|
| 452 | |
---|
| 453 | @property |
---|
[10441] | 454 | def tabletitle(self): |
---|
| 455 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 456 | tabletitle = [] |
---|
| 457 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 458 | target_language=portal_language)) |
---|
| 459 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 460 | target_language=portal_language)) |
---|
| 461 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 462 | target_language=portal_language)) |
---|
| 463 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 464 | target_language=portal_language)) |
---|
| 465 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 466 | target_language=portal_language)) |
---|
| 467 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 468 | target_language=portal_language)) |
---|
| 469 | return tabletitle |
---|
| 470 | |
---|
| 471 | @property |
---|
[9848] | 472 | def label(self): |
---|
| 473 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 474 | lang = self.request.cookies.get('kofa.language', portal_language) |
---|
| 475 | level_title = translate(self.context.level_title, 'waeup.kofa', |
---|
| 476 | target_language=lang) |
---|
| 477 | return translate(_('Course Result Slip'), |
---|
| 478 | 'waeup.uniben', target_language=portal_language) \ |
---|
| 479 | + ' %s' % level_title |
---|
| 480 | |
---|
| 481 | def render(self): |
---|
| 482 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 483 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 484 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 485 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 486 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 487 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
| 488 | Grade = translate('Grade', 'waeup.kofa', target_language=portal_language) |
---|
[9848] | 489 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 490 | self.request, self.omit_fields) |
---|
| 491 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 492 | |
---|
| 493 | tabledata = [] |
---|
| 494 | tableheader = [] |
---|
| 495 | for i in range(1,7): |
---|
| 496 | tabledata.append(sorted( |
---|
| 497 | [value for value in self.context.values() if value.semester == i], |
---|
| 498 | key=lambda value: str(value.semester) + value.code)) |
---|
| 499 | tableheader.append([(Code,'code', 2.5), |
---|
| 500 | (Title,'title', 5), |
---|
| 501 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 502 | (Cred, 'credits', 1.5), |
---|
| 503 | (Grade, 'grade', 1.5), |
---|
| 504 | ]) |
---|
[9908] | 505 | return students_utils.renderPDF( |
---|
| 506 | self, 'course_registration_slip.pdf', |
---|
| 507 | self.context.student, studentview, |
---|
[10441] | 508 | tableheader=tableheader, |
---|
| 509 | tabledata=tabledata, |
---|
[10271] | 510 | omit_fields=self.omit_fields |
---|
[9908] | 511 | ) |
---|
[9686] | 512 | |
---|
| 513 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
---|
| 514 | """ Page to display course tickets |
---|
| 515 | """ |
---|
| 516 | form_fields = grok.AutoFields(ICourseTicket).omit('score') |
---|
[11069] | 517 | |
---|
[13063] | 518 | class CustomStudentActivateView(StudentActivateView): |
---|
[11069] | 519 | """ Activate student account |
---|
| 520 | """ |
---|
| 521 | |
---|
| 522 | def update(self): |
---|
| 523 | self.context.suspended = False |
---|
| 524 | self.context.writeLogMessage(self, 'account activated') |
---|
| 525 | history = IObjectHistory(self.context) |
---|
| 526 | history.addMessage('Student account activated', user='undisclosed') |
---|
| 527 | self.flash(_('Student account has been activated.')) |
---|
| 528 | self.redirect(self.url(self.context)) |
---|
| 529 | return |
---|
| 530 | |
---|
[13063] | 531 | class CustomStudentDeactivateView(StudentDeactivateView): |
---|
[11069] | 532 | """ Deactivate student account |
---|
| 533 | """ |
---|
| 534 | def update(self): |
---|
| 535 | self.context.suspended = True |
---|
| 536 | self.context.writeLogMessage(self, 'account deactivated') |
---|
| 537 | history = IObjectHistory(self.context) |
---|
| 538 | history.addMessage('Student account deactivated', user='undisclosed') |
---|
| 539 | self.flash(_('Student account has been deactivated.')) |
---|
| 540 | self.redirect(self.url(self.context)) |
---|
| 541 | return |
---|
[12845] | 542 | |
---|
[13063] | 543 | class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip): |
---|
[12845] | 544 | """Deliver a PDF slip of the context. |
---|
| 545 | """ |
---|
| 546 | |
---|
[15164] | 547 | #def _sigsInFooter(self): |
---|
| 548 | # isStudent = getattr( |
---|
| 549 | # self.request.principal, 'user_type', None) == 'student' |
---|
| 550 | # if not isStudent: |
---|
| 551 | # return (_('D. R. (Exams & Records)'),_('Current Dean of Faculty'),) |
---|
| 552 | # return () |
---|
[12845] | 553 | |
---|
[14689] | 554 | #def _signatures(self): |
---|
| 555 | # return ([( |
---|
| 556 | # 'Current HD<br /> D. R. (Exams & Records)<br /> ' |
---|
| 557 | # 'For: Registrar')],) |
---|
[12845] | 558 | |
---|
| 559 | def render(self): |
---|
| 560 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 561 | Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language) |
---|
| 562 | Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) |
---|
| 563 | Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) |
---|
| 564 | Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language) |
---|
| 565 | #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) |
---|
| 566 | Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) |
---|
| 567 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 568 | self.request, self.omit_fields) |
---|
| 569 | students_utils = getUtility(IStudentsUtils) |
---|
| 570 | |
---|
| 571 | tableheader = [(Code,'code', 2.5), |
---|
| 572 | (Title,'title', 8.5), |
---|
| 573 | (Term, 'semester', 1.5), |
---|
| 574 | (Cred, 'credits', 1.5), |
---|
| 575 | #(Score, 'score', 1.5), |
---|
| 576 | (Grade, 'grade', 1.5), |
---|
| 577 | ] |
---|
| 578 | |
---|
[15164] | 579 | pdfstream = students_utils.renderPDFTranscript( |
---|
[12845] | 580 | self, 'transcript.pdf', |
---|
| 581 | self.context.student, studentview, |
---|
| 582 | omit_fields=self.omit_fields, |
---|
| 583 | tableheader=tableheader, |
---|
| 584 | signatures=self._signatures(), |
---|
| 585 | sigs_in_footer=self._sigsInFooter(), |
---|
[15164] | 586 | digital_sigs=self._digital_sigs(), |
---|
| 587 | save_file=self._save_file(), |
---|
[13297] | 588 | ) |
---|
[15164] | 589 | if not pdfstream: |
---|
| 590 | self.redirect(self.url(self.context.student)) |
---|
| 591 | return |
---|
| 592 | return pdfstream |
---|
[13297] | 593 | |
---|
| 594 | class CustomExportPDFBedTicketSlip(NigeriaExportPDFBedTicketSlip): |
---|
| 595 | """Deliver a PDF slip of the context. |
---|
| 596 | """ |
---|
| 597 | |
---|
[13317] | 598 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
[13717] | 599 | 'phone', 'adm_code', 'email', 'date_of_birth', 'flash_notice') |
---|
[13297] | 600 | |
---|
[13719] | 601 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 602 | """ Page to manage the student payments. This manage form page is for |
---|
| 603 | both students and students officers. Uniben does not allow students |
---|
| 604 | to remove any payment ticket. |
---|
| 605 | """ |
---|
| 606 | @property |
---|
| 607 | def manage_payments_allowed(self): |
---|
[13723] | 608 | return checkPermission('waeup.manageStudent', self.context) |
---|
[15267] | 609 | |
---|
| 610 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
| 611 | """ Page to manage bed tickets. |
---|
| 612 | This manage form page is for both students and students officers. |
---|
| 613 | """ |
---|
| 614 | with_hostel_selection = True |
---|