## $Id: browser.py 16817 2022-02-17 09:09:52Z 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, StudyLevelManageFormPage, StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, ExportPDFTranscriptSlip, BedTicketAddPage, ExportPDFAdmissionSlip, 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, NigeriaAccommodationManageFormPage, NigeriaAccommodationDisplayFormPage, NigeriaBedTicketAddPage, ) from kofacustom.dspg.students.interfaces import ( ICustomStudentOnlinePayment, ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent) from kofacustom.dspg.interfaces import MessageFactory as _ class CustomBedTicketAddPage(NigeriaBedTicketAddPage): with_ac = False class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): """ View to edit student clearance data by student """ def dataNotComplete(self): store = getUtility(IExtFileStore) if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'): return _('No birth certificate uploaded.') if not store.getFileByContext(self.context, attr=u'lga_ident.jpg'): return _('No LGA identification letter uploaded.') if not store.getFileByContext(self.context, attr=u'o_level_result.jpg'): return _('No O Level result uploaded.') cm = getattr(self.context,'current_mode', None) if cm and cm.startswith('nd'): if not store.getFileByContext(self.context, attr=u'jamb_result.jpg'): return _('No JAMB result uploaded.') elif cm and cm.startswith('hnd'): if not store.getFileByContext(self.context, attr=u'nd_result.jpg'): return _('No ND result uploaded.') if not store.getFileByContext(self.context, attr=u'it_letter.jpg'): return _('No IT letter uploaded.') return False class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): """ Page to display student study levels """ grok.template('studylevelpage') grok.context(ICustomStudentStudyLevel) form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( 'level',) form_fields[ 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 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 CustomStudyLevelManageFormPage(StudyLevelManageFormPage): """ Page to edit the student study level data """ grok.context(ICustomStudentStudyLevel) form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( 'validation_date', 'validated_by', 'total_credits', 'gpa', 'level', 'total_credits_s1', 'total_credits_s2') class CustomExportPDFCourseRegistrationSlip(ExportPDFCourseRegistrationSlip): """Deliver a PDF slip of the context. """ grok.context(ICustomStudentStudyLevel) form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( 'level', 'gpa', 'transcript_remark') form_fields[ 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') prefix = 'form' omit_fields = ( 'password', 'suspended', 'phone', 'date_of_birth', 'adm_code', 'sex', 'suspended_comment', 'current_level', 'flash_notice') 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 pdfstream class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): """ Page to view bed tickets. """ with_hostel_selection = True class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): """ Page to manage bed tickets. This manage form page is for both students and students officers. """ with_hostel_selection = True 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) return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, pre_text='', post_text='') class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): """Deliver a PDF Admission slip. """ @property def pre_text(self): return ( 'I am pleased to inform you that you have been offered ' 'provisional admission into the Delta State Polytechnic, ' 'Ogwashi-Uku as follows:') @property def post_text(self): return """1. Duration: 2 years 2. This offer is conditional upon the confirmation of your qualification(s) as listed by you in the application form or which you claim to possess as at when this offer of admission was made and your meeting the minimum department entry requirement. 3. At the time of Registration, you will be required to produce the original copies of your certificates or any other acceptable evidence of the qualification(s), on which this offer of admission has been based. 4. If at any time after admission it is discovered that you do not possess any of the qualifications which you claimed to have obtained, you will be required to withdraw from the Polytechnic. 5. Please, note that resumption/registration starts immediately. 6. You are required to pay all the necessary fees, such as school fees, students\' union fees, boarding fees (optional) and any other prescribed fees online and register immediately. Late registration will attract severe sanction such as payment of late registration fee of N10000 or outright withdrawal of offer of admission. 7. If you do not respond to this offer within two (2) weeks from the date of resumption, the Polytechnic will assume that you are not interested in the offer and may withdraw the offer to accommodate other candidates on awaiting list. 8. If you do not pay your school fees and register within the stipulated time frame for registration, you would not be allowed to write the Polytechnic\'s semester examinations. Should you mistakenly write the exams, your scripts would not be marked. 9. You are required to present at the time of registration, a letter of attestation from a clergy man, a lawyer, a senior civil servant (Level 13 and above) or any person of reputable standing in the society. 10. Before the commencement of registration, you will be required to undergo a medical examination which should be conducted in the Polytechnic clinic. 11. Other information/instructions about facilities at the Polytechnic, including accommodation, can be obtained from the Polytechnic Portal. The Head of your School/Department at the Polytechnic will make the details of the programme available to you. 12. At the time of registration, you are required to sign an undertaking of non-involvement in cult-related activities and acts of vandalism. 13. We hope that you will be able to take advantage of this offer or provisional admission. 14. Please, accept our hearty congratulations. Admissions Officer For: Registrar """ def render(self): students_utils = getUtility(IStudentsUtils) return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, pre_text=self.pre_text, post_text=self.post_text)