## $Id: browser.py 11873 2014-10-22 14:11:24Z 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.formlib.textwidgets import BytesDisplayWidget from zope.component import getUtility from hurry.workflow.interfaces import IWorkflowInfo from waeup.kofa.interfaces import ADMITTED, IKofaUtils from waeup.kofa.browser.layout import UtilityView from waeup.kofa.students.interfaces import IStudentsUtils from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget from waeup.kofa.students.browser import ( StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage, StudentBasePDFFormPage) from waeup.kwarapoly.students.interfaces import ( ICustomStudent, ICustomStudentBase, ICustomStudentStudyLevel, ICustomUGStudentClearance, ICustomPGStudentClearance) from waeup.kwarapoly.interfaces import MessageFactory as _ from waeup.kofa.students.workflow import ( ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE) from kofacustom.nigeria.students.browser import ( NigeriaOnlinePaymentDisplayFormPage, NigeriaOnlinePaymentAddFormPage, NigeriaExportPDFPaymentSlipPage, NigeriaStudentClearanceDisplayFormPage, NigeriaExportPDFClearanceSlipPage, NigeriaStudentClearanceEditFormPage, NigeriaExportPDFCourseRegistrationSlipPage, NigeriaStudentPersonalDisplayFormPage, NigeriaStudentClearanceManageFormPage, NigeriaStudentPersonalEditFormPage, NigeriaStudentPersonalManageFormPage, NigeriaStudentBaseEditFormPage ) from waeup.kwarapoly.students.interfaces import ( ICustomStudentOnlinePayment, ICustomStudentPersonal, ICustomStudentPersonalEdit ) class CustomStudentBaseEditFormPage(NigeriaStudentBaseEditFormPage): """ View to edit student base data """ form_fields = grok.AutoFields(ICustomStudentBase).select( 'email', 'phone', 'sex') class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage): """ Page to display student personal data """ form_fields = grok.AutoFields(ICustomStudentPersonal) form_fields['perm_address'].custom_widget = BytesDisplayWidget form_fields['next_kin_address'].custom_widget = BytesDisplayWidget form_fields['corr_address'].custom_widget = BytesDisplayWidget form_fields['sponsor_address'].custom_widget = BytesDisplayWidget form_fields[ 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage): """ Page to edit personal data """ form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit( 'personal_updated') class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage): """ Page to edit personal data """ form_fields = grok.AutoFields(ICustomStudentPersonal) form_fields['personal_updated'].for_display = True form_fields[ 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): """ Page to view an online payment ticket """ grok.context(ICustomStudentOnlinePayment) form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') form_fields[ 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') form_fields[ 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): """ Page to add an online payment ticket """ form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( 'p_category') class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): """Deliver a PDF slip of the context. """ grok.context(ICustomStudentOnlinePayment) form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomStartClearancePage(StartClearancePage): with_ac = False class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage): """ Page to display student clearance data """ @property def form_fields(self): if self.context.is_postgrad: form_fields = grok.AutoFields( ICustomPGStudentClearance).omit('clearance_locked') else: form_fields = grok.AutoFields( ICustomUGStudentClearance).omit('clearance_locked') if not getattr(self.context, 'officer_comment'): form_fields = form_fields.omit('officer_comment') else: form_fields['officer_comment'].custom_widget = BytesDisplayWidget return form_fields class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage): """Deliver a PDF slip of the context. """ @property def form_fields(self): if self.context.is_postgrad: form_fields = grok.AutoFields( ICustomPGStudentClearance).omit('clearance_locked') else: form_fields = grok.AutoFields( ICustomUGStudentClearance).omit('clearance_locked') if not getattr(self.context, 'officer_comment'): form_fields = form_fields.omit('officer_comment') return form_fields class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage): """ Page to edit student clearance data """ @property def form_fields(self): if self.context.is_postgrad: form_fields = grok.AutoFields( ICustomPGStudentClearance).omit('clr_code') else: form_fields = grok.AutoFields( ICustomUGStudentClearance).omit('clr_code') return form_fields class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): """ View to edit student clearance data by student """ def dataNotComplete(self): return False @property def form_fields(self): if self.context.is_postgrad: form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment') else: form_fields = grok.AutoFields(ICustomUGStudentClearance).omit( 'clearance_locked', 'clr_code', 'officer_comment') return form_fields class BedTicketAddPage(BedTicketAddPage): """ Page to add an online payment ticket """ buttonname = _('Create bed ticket') notice = '' with_ac = False class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage): """Deliver a PDF Admission slip. """ grok.context(ICustomStudent) omit_fields = ('date_of_birth', 'current_level') form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number') def render(self): if self.context.state in (CREATED, ADMITTED, CLEARANCE, REQUESTED, CLEARED): self.flash('Not allowed.') self.redirect(self.url(self.context)) return students_utils = getUtility(IStudentsUtils) return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields) class ExportPDFAdmissionNotificationPage(UtilityView, grok.View): """Deliver a PDF Admission notification slip. """ grok.context(ICustomStudent) grok.name('admission_notification.pdf') grok.require('waeup.viewStudent') prefix = 'form' label = 'Notification of Provisional Admission' omit_fields = ('date_of_birth', 'current_level') form_fields = grok.AutoFields(ICustomStudent).select( 'student_id', 'reg_number', 'sex', 'lga') def render(self): if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): self.flash('Not allowed.') self.redirect(self.url(self.context)) return students_utils = getUtility(IStudentsUtils) pre_text = '' post_text = post_text_freshers return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, pre_text=pre_text, post_text=post_text) # copied from waeup.aaue class CustomExportPDFCourseRegistrationSlipPage( NigeriaExportPDFCourseRegistrationSlipPage): """Deliver a PDF slip of the context. """ grok.context(ICustomStudentStudyLevel) form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( 'level_session', 'level_verdict', 'validated_by', 'validation_date', 'gpa') omit_fields = ('password', 'suspended', 'suspended_comment', 'phone', 'adm_code', 'sex', 'email', 'date_of_birth', 'department', 'current_mode', 'current_level') @property def title(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE return translate(_('Credits Registered'), 'waeup.kofa', target_language=portal_language) def _signatures(self): return ( [('I have selected the course on the advise of my Head of ' 'Department.
', _('Student\'s Signature'), '
')], [('This student has satisfied the department\'s requirements. ' 'I recommend to approve the course registration.
', _('Head of Department\'s Signature'), '
')], [('' , _('Principal Assistant Registrar\'s Signature'), '
')], [('', _('Director\'s Signature'))] ) def render(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE Sem = translate('Sem.', '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('Cred.', 'waeup.kofa', target_language=portal_language) Score = translate('Score', 'waeup.kofa', target_language=portal_language) Grade = translate('Grade', 'waeup.kofa', target_language=portal_language) Signature = translate(_('HOD\'s Signature'), 'waeup.kwarapoly', target_language=portal_language) studentview = StudentBasePDFFormPage(self.context.student, self.request, self.omit_fields) students_utils = getUtility(IStudentsUtils) tabledata = [] tableheader = [] contenttitle = [] 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.0), (Title,'title', 7), (Cred, 'credits', 1.5), (Score, 'score', 1.4), (Grade, 'grade', 1.4), (Signature, 'dummy', 3), ]) if len(self.label.split('\n')) == 3: topMargin = 1.9 elif len(self.label.split('\n')) == 2: topMargin = 1.7 else: topMargin = 1.5 return students_utils.renderPDF( self, 'course_registration_slip.pdf', self.context.student, studentview, tableheader=tableheader, tabledata=tabledata, signatures=self._signatures(), topMargin=topMargin, omit_fields=self.omit_fields ) class ExportPDFRegistrationSlipPage(grok.View): """Deliver a PDF slip of the context. """ grok.context(ICustomStudent) grok.name('registration_slip.pdf') grok.require('waeup.viewStudent') prefix = 'form' omit_fields = ( 'suspended', 'phone', 'adm_code', 'suspended_comment', 'email', 'current_mode', 'matric_number', 'date_of_birth', 'current_level') title = 'Clearance and Personal Data' label = 'Profile Registration Slip' form_fields = grok.AutoFields(ICustomStudent).select( 'date_of_birth', 'lga', 'nationality', 'perm_address', 'corr_address', 'marit_stat', 'sponsor_name', 'sponsor_address', ) def render(self): studentview = StudentBasePDFFormPage(self.context.student, self.request, self.omit_fields) students_utils = getUtility(IStudentsUtils) return students_utils.renderPDF( self, 'registration_slip.pdf', self.context.student, studentview, signatures=None, omit_fields=self.omit_fields, note=post_text_registration) post_text_registration = """

IMPORTANT NOTICE

This registration slip must be supplied before attendance of lectures. Note that:

1. All fees due must be paid in full.

2. All information required must be available on the Registration Form.

3. The Signature of all appropriate Polytechnic Authority must be obtained.

4. The endorsed Registration Form should be returned to the respective Institutes and Administrative Offices.

5. No student may change his subject or course of study as shown in the signed Registration Form without clearance from the Admissions Office and the Director of the appropriate Institute.

6. All candidates admitted into the HND I programmes should submit the photocopies of their original certificates of ND and SSCE with scratch card online for clearance latest a week after the admission is offered. Failure to comply with this directive may lead to the forfeiture of the admission.

M.O. Adebayo
Admission Officer
For: Registrar """ post_text_freshers = """ INSTRUCTIONS TO FRESHERS

You are hereby offered a provisional admission for the 2014/2015 session subject to the conditions that:

1. The information given in your Application Form is correct.

2. The original of your Credentials are presented for scrutiny.

3. If at any time the Credentials submitted are found to be false/fake or incorrect, your admission shall be withdrawn.

4. The name by which you are admitted and registered shall remain same throughout the duration of your programme.

5. You are to fill and submit the Undertaking Form at the point of registration failure which your admission will be forfeited.

6. You will dress decently covering your nakedness at all times.

7. Payment of school fees will be once and in full and should be by Interswitch to the designated Banks. Failure to pay fees by the mode mentioned above by the closing date means you have declined the offer and your place will be given to another eligible candidate immediately.

8. You present a Certificate of medical fitness from the Polytechnic Clinic.

9. All indigenes of Kwara State are required to present Certificate of Citizenship.

10. The Polytechnic reserves the right to withdraw your admission at any stage, if you are found to be a cultist or an expelled individual from any tertiary institution.

11. You are prepared to take up accommodation provided on the campuses by the authority.

12. There will be no refund of school fees once paid.

13. If you accept this offer with the above stated conditions, please make a photocopy of this document and return it to the Admission Office immediately.

14. You possess the entry requirement for the programme you are admitted.

M.O. Adebayo
Admission Officer
For: Registrar """