[8911] | 1 | ## $Id: browser.py 12879 2015-04-23 21:13:40Z 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 |
---|
[9210] | 20 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
[12856] | 21 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[9380] | 22 | from zope.component import getUtility |
---|
[9281] | 23 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[11069] | 24 | from waeup.kofa.interfaces import ( |
---|
| 25 | REQUESTED, IExtFileStore, IKofaUtils, IObjectHistory) |
---|
[8911] | 26 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[12121] | 27 | from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView |
---|
[9205] | 28 | from waeup.kofa.students.browser import ( |
---|
[9686] | 29 | StudyLevelEditFormPage, StudyLevelDisplayFormPage, |
---|
| 30 | StudentBasePDFFormPage, ExportPDFCourseRegistrationSlipPage, |
---|
[10025] | 31 | CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, |
---|
[11069] | 32 | msave, emit_lock_message, |
---|
[12845] | 33 | StudentActivatePage, StudentDeactivatePage, |
---|
| 34 | ExportPDFTranscriptPage) |
---|
| 35 | from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID, |
---|
| 36 | CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, |
---|
| 37 | GRADUATED, TRANSCRIPT, FORBIDDEN_POSTGRAD_TRANS) |
---|
[9686] | 38 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
---|
[9251] | 39 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
[8911] | 40 | from kofacustom.nigeria.students.browser import ( |
---|
| 41 | NigeriaOnlinePaymentDisplayFormPage, |
---|
[9251] | 42 | NigeriaStudentBaseManageFormPage, |
---|
[9380] | 43 | NigeriaStudentClearanceEditFormPage, |
---|
[8911] | 44 | NigeriaOnlinePaymentAddFormPage, |
---|
[9281] | 45 | NigeriaExportPDFPaymentSlipPage, |
---|
[9551] | 46 | NigeriaExportPDFClearanceSlipPage, |
---|
[12856] | 47 | NigeriaStudentPersonalDisplayFormPage, |
---|
| 48 | NigeriaStudentPersonalManageFormPage |
---|
[9281] | 49 | ) |
---|
[8911] | 50 | |
---|
[9210] | 51 | from waeup.uniben.students.interfaces import ( |
---|
[12121] | 52 | ICustomStudent, |
---|
[12856] | 53 | ICustomStudentOnlinePayment, |
---|
| 54 | ICustomStudentStudyCourse, |
---|
[11552] | 55 | ICustomStudentStudyLevel, |
---|
| 56 | ICustomUGStudentClearance, |
---|
[12856] | 57 | ICustomPGStudentClearance, |
---|
| 58 | ICustomStudentPersonal) |
---|
[9210] | 59 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8911] | 60 | |
---|
| 61 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 62 | """ Page to view an online payment ticket |
---|
| 63 | """ |
---|
| 64 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 65 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9993] | 66 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 67 | form_fields[ |
---|
| 68 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 69 | form_fields[ |
---|
| 70 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 71 | |
---|
[9380] | 72 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 73 | """ View to edit student clearance data by student |
---|
| 74 | """ |
---|
| 75 | |
---|
[11552] | 76 | @property |
---|
| 77 | def form_fields(self): |
---|
| 78 | if self.context.is_postgrad: |
---|
| 79 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( |
---|
[12391] | 80 | 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment', |
---|
| 81 | 'physical_clearance_date') |
---|
[11552] | 82 | else: |
---|
| 83 | form_fields = grok.AutoFields(ICustomUGStudentClearance).omit( |
---|
[12391] | 84 | 'clearance_locked', 'clr_code', 'officer_comment', |
---|
| 85 | 'physical_clearance_date') |
---|
[11552] | 86 | form_fields['date_of_birth'].for_display = True |
---|
| 87 | form_fields['nationality'].for_display = True |
---|
| 88 | form_fields['lga'].for_display = True |
---|
| 89 | return form_fields |
---|
| 90 | |
---|
[9380] | 91 | def dataNotComplete(self): |
---|
| 92 | store = getUtility(IExtFileStore) |
---|
| 93 | if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'): |
---|
| 94 | return _('No birth certificate uploaded.') |
---|
| 95 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
| 96 | return _('No guarantor/referee letter uploaded.') |
---|
| 97 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
| 98 | return _('No acceptance letter uploaded.') |
---|
| 99 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
| 100 | return _('No first sitting result uploaded.') |
---|
[9395] | 101 | #if not store.getFileByContext(self.context, attr=u'scd_sit_scan.jpg'): |
---|
| 102 | # return _('No second sitting result uploaded.') |
---|
[9380] | 103 | if not store.getFileByContext(self.context, attr=u'secr_cults.jpg'): |
---|
[9848] | 104 | return _('No affidavit of non-membership of secret cults uploaded.') |
---|
[9380] | 105 | return False |
---|
| 106 | |
---|
[8911] | 107 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 108 | """ Page to add an online payment ticket |
---|
| 109 | """ |
---|
| 110 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
| 111 | 'p_category') |
---|
| 112 | |
---|
| 113 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
| 114 | """Deliver a PDF slip of the context. |
---|
| 115 | """ |
---|
| 116 | grok.context(ICustomStudentOnlinePayment) |
---|
[9775] | 117 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9993] | 118 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 119 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9205] | 120 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 121 | |
---|
| 122 | |
---|
[9551] | 123 | class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage): |
---|
| 124 | """Deliver a PDF slip of the context. |
---|
| 125 | """ |
---|
| 126 | |
---|
[11537] | 127 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
| 128 | 'phone', 'adm_code', 'email', 'date_of_birth') |
---|
| 129 | |
---|
[12846] | 130 | def _sigsInFooter(self): |
---|
[12845] | 131 | isStudent = getattr( |
---|
| 132 | self.request.principal, 'user_type', None) == 'student' |
---|
[12852] | 133 | if not isStudent and self.context.state in (CLEARED, RETURNING): |
---|
[12846] | 134 | return (_('Date, Student Signature'), |
---|
| 135 | _('Date, Clearance Officer Signature'), |
---|
| 136 | ) |
---|
| 137 | return () |
---|
[12845] | 138 | |
---|
[9551] | 139 | def render(self): |
---|
| 140 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 141 | self.request, self.omit_fields) |
---|
| 142 | students_utils = getUtility(IStudentsUtils) |
---|
| 143 | return students_utils.renderPDF( |
---|
| 144 | self, 'clearance_slip.pdf', |
---|
| 145 | self.context.student, studentview, signatures=self._signatures(), |
---|
[10271] | 146 | sigs_in_footer=self._sigsInFooter(), show_scans=False, |
---|
| 147 | omit_fields=self.omit_fields) |
---|
[9551] | 148 | |
---|
[12121] | 149 | |
---|
| 150 | class ExportClearanceInvitationSlipPage(UtilityView, grok.View): |
---|
| 151 | """Deliver an invitation letter to physical clearance. |
---|
| 152 | |
---|
| 153 | This form page is available only in Uniben. |
---|
| 154 | """ |
---|
| 155 | grok.context(ICustomStudent) |
---|
| 156 | grok.name('clearance_invitation_slip.pdf') |
---|
| 157 | grok.require('waeup.viewStudent') |
---|
| 158 | prefix = 'form' |
---|
| 159 | |
---|
[12263] | 160 | label = u'Invitation Letter for Physical Clearance' |
---|
[12121] | 161 | |
---|
| 162 | omit_fields = ( |
---|
| 163 | 'suspended', 'phone', 'email', |
---|
| 164 | 'adm_code', 'suspended_comment', |
---|
| 165 | 'date_of_birth', 'current_level', |
---|
[12150] | 166 | 'department', 'current_mode', |
---|
[12121] | 167 | 'entry_session', 'matric_number', 'sex') |
---|
| 168 | |
---|
| 169 | form_fields = [] |
---|
| 170 | |
---|
| 171 | @property |
---|
| 172 | def note(self): |
---|
| 173 | if self.context.physical_clearance_date: |
---|
| 174 | return """ |
---|
[12147] | 175 | <br /><br /><br /><br /><font size='12'> |
---|
| 176 | Dear %s, |
---|
| 177 | <br /><br /><br /> |
---|
[12264] | 178 | You are invited for your physical clearance on: |
---|
[12121] | 179 | <br /><br /> |
---|
[12264] | 180 | <strong>%s</strong>. |
---|
| 181 | <br /><br /> |
---|
[12265] | 182 | Please bring along this letter of invitation to the University Main Auditorium |
---|
[12147] | 183 | <br /><br /> |
---|
[12263] | 184 | on your clearance date. |
---|
[12147] | 185 | <br /><br /><br /> |
---|
[12263] | 186 | Signed, |
---|
[12147] | 187 | <br /><br /> |
---|
| 188 | The Registrar<br /> |
---|
[12121] | 189 | </font> |
---|
| 190 | |
---|
[12147] | 191 | """ % (self.context.display_fullname, self.context.physical_clearance_date) |
---|
[12121] | 192 | return |
---|
| 193 | |
---|
[12122] | 194 | |
---|
| 195 | def update(self): |
---|
| 196 | if self.context.student.state != REQUESTED \ |
---|
| 197 | or not self.context.student.physical_clearance_date: |
---|
| 198 | self.flash(_('Forbidden'), type="warning") |
---|
| 199 | self.redirect(self.url(self.context)) |
---|
| 200 | |
---|
[12121] | 201 | def render(self): |
---|
| 202 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 203 | self.request, self.omit_fields) |
---|
| 204 | students_utils = getUtility(IStudentsUtils) |
---|
| 205 | return students_utils.renderPDF( |
---|
| 206 | self, 'clearance_invitation_slip', |
---|
| 207 | self.context.student, studentview, |
---|
| 208 | omit_fields=self.omit_fields, |
---|
| 209 | note=self.note) |
---|
| 210 | |
---|
[12856] | 211 | class CustomStudentPersonalDisplayFormPage( |
---|
| 212 | NigeriaStudentPersonalDisplayFormPage): |
---|
| 213 | """ Page to display student personal data |
---|
| 214 | """ |
---|
| 215 | |
---|
| 216 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 217 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 218 | form_fields['next_kin_address'].custom_widget = BytesDisplayWidget |
---|
| 219 | form_fields[ |
---|
| 220 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 221 | |
---|
| 222 | class CustomStudentPersonalManageFormPage( |
---|
| 223 | NigeriaStudentPersonalManageFormPage): |
---|
| 224 | """ Page to manage personal data |
---|
| 225 | """ |
---|
| 226 | |
---|
| 227 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 228 | form_fields['personal_updated'].for_display = True |
---|
| 229 | form_fields[ |
---|
| 230 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 231 | |
---|
[9210] | 232 | class StudyCourseCOEditFormPage(KofaEditFormPage): |
---|
[9281] | 233 | """ Page to edit the student study course data by clearance officers. |
---|
[9210] | 234 | |
---|
| 235 | This form page is available only in Uniben. |
---|
| 236 | """ |
---|
| 237 | grok.context(ICustomStudentStudyCourse) |
---|
| 238 | grok.name('edit_level') |
---|
| 239 | grok.require('waeup.clearStudent') |
---|
| 240 | label = _('Edit current level') |
---|
| 241 | pnav = 4 |
---|
| 242 | form_fields = grok.AutoFields( |
---|
| 243 | ICustomStudentStudyCourse).select('current_level') |
---|
| 244 | |
---|
| 245 | def update(self): |
---|
| 246 | if not (self.context.is_current and |
---|
| 247 | self.context.student.state == REQUESTED): |
---|
| 248 | emit_lock_message(self) |
---|
| 249 | return |
---|
| 250 | super(StudyCourseCOEditFormPage, self).update() |
---|
| 251 | return |
---|
| 252 | |
---|
| 253 | @action(_('Save'), style='primary') |
---|
| 254 | def save(self, **data): |
---|
| 255 | try: |
---|
| 256 | msave(self, **data) |
---|
| 257 | except ConstraintNotSatisfied: |
---|
| 258 | # The selected level might not exist in certificate |
---|
| 259 | self.flash(_('Current level not available for certificate.')) |
---|
| 260 | return |
---|
| 261 | #notify(grok.ObjectModifiedEvent(self.context.__parent__)) |
---|
[9281] | 262 | return |
---|
| 263 | |
---|
| 264 | class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): |
---|
| 265 | """ Page to edit the student study level data by students. |
---|
| 266 | |
---|
| 267 | """ |
---|
[9686] | 268 | grok.template('studyleveleditpage') |
---|
[9281] | 269 | |
---|
[9686] | 270 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 271 | """ Page to display student study levels |
---|
| 272 | """ |
---|
| 273 | grok.template('studylevelpage') |
---|
| 274 | |
---|
| 275 | class CustomExportPDFCourseRegistrationSlipPage( |
---|
| 276 | ExportPDFCourseRegistrationSlipPage): |
---|
| 277 | """Deliver a PDF slip of the context. |
---|
| 278 | """ |
---|
| 279 | |
---|
[9921] | 280 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
---|
[12879] | 281 | 'level_verdict', 'gpa', 'level') |
---|
[9921] | 282 | |
---|
[12855] | 283 | def update(self): |
---|
| 284 | if self.context.student.state != REGISTERED \ |
---|
| 285 | or self.context.student.current_level != self.context.level: |
---|
| 286 | self.flash(_('Forbidden'), type="warning") |
---|
| 287 | self.redirect(self.url(self.context)) |
---|
| 288 | |
---|
[10441] | 289 | @property |
---|
| 290 | def tabletitle(self): |
---|
| 291 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 292 | tabletitle = [] |
---|
| 293 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 294 | target_language=portal_language)) |
---|
| 295 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 296 | target_language=portal_language)) |
---|
| 297 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 298 | target_language=portal_language)) |
---|
| 299 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 300 | target_language=portal_language)) |
---|
| 301 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 302 | target_language=portal_language)) |
---|
| 303 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 304 | target_language=portal_language)) |
---|
| 305 | return tabletitle |
---|
| 306 | |
---|
[9686] | 307 | def render(self): |
---|
| 308 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 309 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 310 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 311 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 312 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 313 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
[9686] | 314 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 315 | self.request, self.omit_fields) |
---|
| 316 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 317 | |
---|
| 318 | tabledata = [] |
---|
| 319 | tableheader = [] |
---|
| 320 | contenttitle = [] |
---|
| 321 | for i in range(1,7): |
---|
| 322 | tabledata.append(sorted( |
---|
| 323 | [value for value in self.context.values() if value.semester == i], |
---|
| 324 | key=lambda value: str(value.semester) + value.code)) |
---|
| 325 | tableheader.append([(Code,'code', 2.5), |
---|
| 326 | (Title,'title', 5), |
---|
| 327 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 328 | (Cred, 'credits', 1.5), |
---|
| 329 | ]) |
---|
[9686] | 330 | return students_utils.renderPDF( |
---|
| 331 | self, 'course_registration_slip.pdf', |
---|
| 332 | self.context.student, studentview, |
---|
[10441] | 333 | tableheader=tableheader, |
---|
| 334 | tabledata=tabledata, |
---|
[10271] | 335 | omit_fields=self.omit_fields |
---|
[9908] | 336 | ) |
---|
[9848] | 337 | |
---|
| 338 | class UnibenExportPDFCourseResultSlipPage(ExportPDFCourseRegistrationSlipPage): |
---|
| 339 | """Deliver a PDF slip of the context. |
---|
| 340 | """ |
---|
| 341 | |
---|
| 342 | grok.name('course_result_slip.pdf') |
---|
| 343 | |
---|
| 344 | @property |
---|
[10441] | 345 | def tabletitle(self): |
---|
| 346 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 347 | tabletitle = [] |
---|
| 348 | tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa', |
---|
| 349 | target_language=portal_language)) |
---|
| 350 | tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa', |
---|
| 351 | target_language=portal_language)) |
---|
| 352 | tabletitle.append(translate(_('Level Courses'), 'waeup.kofa', |
---|
| 353 | target_language=portal_language)) |
---|
| 354 | tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa', |
---|
| 355 | target_language=portal_language)) |
---|
| 356 | tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa', |
---|
| 357 | target_language=portal_language)) |
---|
| 358 | tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa', |
---|
| 359 | target_language=portal_language)) |
---|
| 360 | return tabletitle |
---|
| 361 | |
---|
| 362 | @property |
---|
[9848] | 363 | def label(self): |
---|
| 364 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 365 | lang = self.request.cookies.get('kofa.language', portal_language) |
---|
| 366 | level_title = translate(self.context.level_title, 'waeup.kofa', |
---|
| 367 | target_language=lang) |
---|
| 368 | return translate(_('Course Result Slip'), |
---|
| 369 | 'waeup.uniben', target_language=portal_language) \ |
---|
| 370 | + ' %s' % level_title |
---|
| 371 | |
---|
| 372 | def render(self): |
---|
| 373 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[9909] | 374 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 375 | Title = translate('Title', 'waeup.kofa', target_language=portal_language) |
---|
| 376 | Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language) |
---|
| 377 | Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language) |
---|
| 378 | Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language) |
---|
| 379 | Grade = translate('Grade', 'waeup.kofa', target_language=portal_language) |
---|
[9848] | 380 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 381 | self.request, self.omit_fields) |
---|
| 382 | students_utils = getUtility(IStudentsUtils) |
---|
[10441] | 383 | |
---|
| 384 | tabledata = [] |
---|
| 385 | tableheader = [] |
---|
| 386 | contenttitle = [] |
---|
| 387 | for i in range(1,7): |
---|
| 388 | tabledata.append(sorted( |
---|
| 389 | [value for value in self.context.values() if value.semester == i], |
---|
| 390 | key=lambda value: str(value.semester) + value.code)) |
---|
| 391 | tableheader.append([(Code,'code', 2.5), |
---|
| 392 | (Title,'title', 5), |
---|
| 393 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
---|
| 394 | (Cred, 'credits', 1.5), |
---|
| 395 | (Grade, 'grade', 1.5), |
---|
| 396 | ]) |
---|
[9908] | 397 | return students_utils.renderPDF( |
---|
| 398 | self, 'course_registration_slip.pdf', |
---|
| 399 | self.context.student, studentview, |
---|
[10441] | 400 | tableheader=tableheader, |
---|
| 401 | tabledata=tabledata, |
---|
[10271] | 402 | omit_fields=self.omit_fields |
---|
[9908] | 403 | ) |
---|
[9686] | 404 | |
---|
| 405 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
---|
| 406 | """ Page to display course tickets |
---|
| 407 | """ |
---|
| 408 | form_fields = grok.AutoFields(ICourseTicket).omit('score') |
---|
[11069] | 409 | |
---|
| 410 | class CustomStudentActivatePage(StudentActivatePage): |
---|
| 411 | """ Activate student account |
---|
| 412 | """ |
---|
| 413 | |
---|
| 414 | def update(self): |
---|
| 415 | self.context.suspended = False |
---|
| 416 | self.context.writeLogMessage(self, 'account activated') |
---|
| 417 | history = IObjectHistory(self.context) |
---|
| 418 | history.addMessage('Student account activated', user='undisclosed') |
---|
| 419 | self.flash(_('Student account has been activated.')) |
---|
| 420 | self.redirect(self.url(self.context)) |
---|
| 421 | return |
---|
| 422 | |
---|
| 423 | class CustomStudentDeactivatePage(StudentDeactivatePage): |
---|
| 424 | """ Deactivate student account |
---|
| 425 | """ |
---|
| 426 | def update(self): |
---|
| 427 | self.context.suspended = True |
---|
| 428 | self.context.writeLogMessage(self, 'account deactivated') |
---|
| 429 | history = IObjectHistory(self.context) |
---|
| 430 | history.addMessage('Student account deactivated', user='undisclosed') |
---|
| 431 | self.flash(_('Student account has been deactivated.')) |
---|
| 432 | self.redirect(self.url(self.context)) |
---|
| 433 | return |
---|
[12845] | 434 | |
---|
| 435 | class CustomExportPDFTranscriptPage(ExportPDFTranscriptPage): |
---|
| 436 | """Deliver a PDF slip of the context. |
---|
| 437 | """ |
---|
| 438 | |
---|
| 439 | def _sigsInFooter(self): |
---|
| 440 | return [] |
---|
| 441 | #return (_('CERTIFIED TRUE COPY'),) |
---|
| 442 | |
---|
| 443 | def _signatures(self): |
---|
| 444 | return ([( |
---|
| 445 | 'Current HD<br /> D. R. (Exams & Records)<br /> ' |
---|
| 446 | 'For: Registrar')],) |
---|
| 447 | |
---|
| 448 | def render(self): |
---|
| 449 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 450 | Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language) |
---|
| 451 | Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) |
---|
| 452 | Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) |
---|
| 453 | Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language) |
---|
| 454 | #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) |
---|
| 455 | Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) |
---|
| 456 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 457 | self.request, self.omit_fields) |
---|
| 458 | students_utils = getUtility(IStudentsUtils) |
---|
| 459 | |
---|
| 460 | tableheader = [(Code,'code', 2.5), |
---|
| 461 | (Title,'title', 8.5), |
---|
| 462 | (Term, 'semester', 1.5), |
---|
| 463 | (Cred, 'credits', 1.5), |
---|
| 464 | #(Score, 'score', 1.5), |
---|
| 465 | (Grade, 'grade', 1.5), |
---|
| 466 | ] |
---|
| 467 | |
---|
| 468 | return students_utils.renderPDFTranscript( |
---|
| 469 | self, 'transcript.pdf', |
---|
| 470 | self.context.student, studentview, |
---|
| 471 | omit_fields=self.omit_fields, |
---|
| 472 | tableheader=tableheader, |
---|
| 473 | signatures=self._signatures(), |
---|
| 474 | sigs_in_footer=self._sigsInFooter(), |
---|
| 475 | ) |
---|