## $Id: browser.py 15185 2018-10-12 15:51:59Z henrik $ ## ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import grok from zope.i18n import translate from zope.schema.interfaces import ConstraintNotSatisfied from zope.component import getUtility from hurry.workflow.interfaces import IWorkflowInfo from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget from waeup.kofa.browser.layout import ( KofaEditFormPage, UtilityView, action, jsaction) from waeup.kofa.students.browser import ( StudyLevelEditFormPage, StudyLevelDisplayFormPage, StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, BedTicketAddPage, ExportPDFTranscriptSlip, msave, emit_lock_message) from waeup.kofa.students.interfaces import ( IStudentsUtils, ICourseTicket, IStudent) from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS, PAID from kofacustom.nigeria.students.browser import ( NigeriaOnlinePaymentDisplayFormPage, NigeriaStudentBaseManageFormPage, NigeriaStudentClearanceEditFormPage, NigeriaOnlinePaymentAddFormPage, NigeriaExportPDFPaymentSlip, NigeriaExportPDFClearanceSlip, ) from kofacustom.edopoly.students.interfaces import ( ICustomStudentOnlinePayment, ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent) from kofacustom.edopoly.interfaces import MessageFactory as _ class CustomBedTicketAddPage(BedTicketAddPage): with_ac = False class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): """ Page to display student study levels """ grok.template('studylevelpage') class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): """ Page to edit the student study level data by students. """ grok.template('studyleveleditpage') class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): """ Page to display course tickets """ form_fields = grok.AutoFields(ICourseTicket).omit('score') class CustomExportPDFCourseRegistrationSlip(ExportPDFCourseRegistrationSlip): """Deliver a PDF slip of the context. """ def render(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language) Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language) Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language) #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language) #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) studentview = StudentBasePDFFormPage(self.context.student, self.request, self.omit_fields) students_utils = getUtility(IStudentsUtils) tabledata = [] tableheader = [] for i in range(1,7): tabledata.append(sorted( [value for value in self.context.values() if value.semester == i], key=lambda value: str(value.semester) + value.code)) tableheader.append([(Code,'code', 2.5), (Title,'title', 5), (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), (Cred, 'credits', 1.5), #(Mand, 'mandatory', 1.5), #(Score, 'score', 1.5), (Grade, 'grade', 1.5), #('Auto', 'automatic', 1.5) ]) return students_utils.renderPDF( self, 'course_registration_slip.pdf', self.context.student, studentview, tableheader=tableheader, tabledata=tabledata, omit_fields=self.omit_fields ) class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip): """Deliver a PDF slip of the context. """ def render(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language) Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language) #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) studentview = StudentBasePDFFormPage(self.context.student, self.request, self.omit_fields) students_utils = getUtility(IStudentsUtils) tableheader = [(Code,'code', 2.5), (Title,'title', 8.5), (Term, 'semester', 1.5), (Cred, 'credits', 1.5), #(Score, 'score', 1.5), (Grade, 'grade', 1.5), ] pdfstream = students_utils.renderPDFTranscript( self, 'transcript.pdf', self.context.student, studentview, omit_fields=self.omit_fields, tableheader=tableheader, signatures=self._signatures(), sigs_in_footer=self._sigsInFooter(), digital_sigs=self._digital_sigs(), save_file=self._save_file(), ) if not pdfstream: self.redirect(self.url(self.context.student)) return return class StudentGetMatricNumberPage(UtilityView, grok.View): """ Construct and set the matriculation number. """ grok.context(IStudent) grok.name('get_matric_number') grok.require('waeup.viewStudent') def update(self): students_utils = getUtility(IStudentsUtils) msg, mnumber = students_utils.setMatricNumber(self.context) if msg: self.flash(msg, type="danger") else: self.flash(_('Matriculation number %s assigned.' % mnumber)) self.context.writeLogMessage(self, '%s assigned' % mnumber) self.redirect(self.url(self.context)) return def render(self): return class ExportPDFMatricNumberSlip(UtilityView, grok.View): """Deliver a PDF notification slip. """ grok.context(ICustomStudent) grok.name('matric_number_slip.pdf') grok.require('waeup.viewStudent') prefix = 'form' form_fields = grok.AutoFields(ICustomStudent).select( 'student_id', 'matric_number') omit_fields = ('date_of_birth', 'current_level', 'flash_notice') @property def title(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE return translate(_('Matriculation Number'), 'waeup.kofa', target_language=portal_language) @property def label(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE return translate(_('Matriculation Number Slip\n'), target_language=portal_language) \ + ' %s' % self.context.display_fullname def render(self): if self.context.state not in (PAID,) or not self.context.is_fresh \ or not self.context.matric_number: self.flash('Not allowed.', type="danger") self.redirect(self.url(self.context)) return students_utils = getUtility(IStudentsUtils) pre_text = _('Congratulations! Your acceptance fee and school fees ' + 'payments have been received and your matriculation ' + 'number generated with details as follows.') return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, pre_text=pre_text, post_text='') class MedicalLaboratoryRequestForm(UtilityView, grok.View): """Deliver a PDF notification slip. """ grok.context(ICustomStudent) grok.name('medical_laboratory_form.pdf') grok.require('waeup.viewStudent') prefix = 'form' form_fields = grok.AutoFields(ICustomStudent).select( 'student_id', 'matric_number', 'sex', 'email', 'phone', 'perm_address') omit_fields = ('current_mode') label = u'Student\'s Medical Laboratory Request Form' title = u'Student\'s Medical Laboratory Request Form' post_text = """ Laboratory request: Student's Medical Test Lab Results/Status: Medical Laboratory Scientist's Sign.: Notice to all newly admitted students: 1. Carry out your mandatory medical laboratory tests at: (a) the Edo State Polyechnic Health Centre 2. Evidence of medical screening payment and the downloaded student's laboratory test request form are required for the medical tests to be conducted for students. 3. Collect your lab tests results and upload during clearance process online. 4. Students' admission records and clearance are incomplete without medical test result. 5. Results of medical tests from elsewhere are not accepted. 6. Medical tests are conducted only within admission period, and will end in matriculation week. Unnecessary delays will not be allowed. 7. This information applies to both full- time and part-time. """ def render(self): if not self.context.medical_fee_paid: self.flash('Not allowed.', type="danger") self.redirect(self.url(self.context)) return students_utils = getUtility(IStudentsUtils) return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, pre_text='', post_text=self.post_text)