[8911] | 1 | ## $Id: browser.py 15961 2020-01-27 13:03:41Z 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 |
---|
[15887] | 19 | import os |
---|
[8911] | 20 | from zope.i18n import translate |
---|
[9945] | 21 | from zope.component import getUtility |
---|
[15304] | 22 | from zope.security import checkPermission |
---|
[9156] | 23 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[9945] | 24 | from waeup.kofa.interfaces import ADMITTED, IKofaUtils |
---|
[9156] | 25 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[8911] | 26 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[15507] | 27 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[9945] | 28 | from waeup.kofa.students.browser import ( |
---|
[15717] | 29 | StartClearancePage, |
---|
[15304] | 30 | ExportPDFAdmissionSlip, StudyLevelDisplayFormPage, |
---|
[15940] | 31 | PaymentsManageFormPage, |
---|
| 32 | OnlinePaymentApproveView) |
---|
[8911] | 33 | from kofacustom.nigeria.students.browser import ( |
---|
| 34 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 35 | NigeriaOnlinePaymentAddFormPage, |
---|
[13060] | 36 | NigeriaExportPDFPaymentSlip, |
---|
[9190] | 37 | NigeriaStudentClearanceEditFormPage, |
---|
[14591] | 38 | NigeriaExportPDFClearanceSlip, |
---|
[15717] | 39 | NigeriaExportPDFCourseRegistrationSlip, |
---|
| 40 | NigeriaBedTicketAddPage, |
---|
[9190] | 41 | ) |
---|
[8911] | 42 | |
---|
[10019] | 43 | from waeup.fceokene.students.interfaces import ( |
---|
[14591] | 44 | ICustomStudentOnlinePayment, ICustomUGStudentClearance, |
---|
| 45 | ICustomStudentStudyLevel) |
---|
[8911] | 46 | |
---|
[13060] | 47 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
[9945] | 48 | """Deliver a PDF Admission slip. |
---|
| 49 | """ |
---|
| 50 | |
---|
| 51 | @property |
---|
| 52 | def label(self): |
---|
| 53 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 54 | line0 = '' |
---|
| 55 | if self.context.student.current_mode.startswith('ug'): |
---|
| 56 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
| 57 | line1 = translate(_('Admission Letter of'), |
---|
| 58 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 59 | + ' %s' % self.context.display_fullname |
---|
| 60 | return '%s%s' % (line0, line1) |
---|
| 61 | |
---|
[15507] | 62 | @property |
---|
| 63 | def _post_text(self): |
---|
| 64 | return """You should note the following as conditions for admission: |
---|
| 65 | |
---|
[15887] | 66 | 1. At the point of registration, you will be required to present the originals of your certificate(s), |
---|
| 67 | Jamb Original Result, a Birth Certificate or a Declaration of Age Certificate and Evidence of |
---|
| 68 | Citizenship Certificate. |
---|
[15690] | 69 | |
---|
[15887] | 70 | 2. Please note that the name by which you are hereby admitted and by which you will be registered |
---|
| 71 | is the one which will appear on any certificate that the Federal College of Education, Okene may |
---|
| 72 | issue to you on successful completion of your programme except there was a change of name by |
---|
| 73 | sworn affidavit or marriage certificate in addition to newspaper publication. |
---|
[15690] | 74 | |
---|
[15887] | 75 | 3. You are hereby informed that all fees must be paid at the beginning of the academic session. |
---|
| 76 | The current school fees can be obtained from the College website. |
---|
[15690] | 77 | |
---|
[15887] | 78 | 4. You will present at the time of registration the Medical Certificate of Fitness from the Federal |
---|
| 79 | College of Education, Okene Medical Centre. |
---|
[15690] | 80 | |
---|
[15887] | 81 | 5. Please, note that due to shortage of accommodations, students shall be given accommodations |
---|
| 82 | on first come, first serve basis. |
---|
[15690] | 83 | |
---|
[15509] | 84 | 6. The offer is not transferable to another session. |
---|
[15507] | 85 | |
---|
[15887] | 86 | 7. You will sign a declaration of good conduct except by deferment on your arrival at the College. |
---|
[15690] | 87 | |
---|
[15507] | 88 | Accept my congratulations. |
---|
| 89 | |
---|
| 90 | Yours faithfully |
---|
| 91 | |
---|
| 92 | M. S. Adoke |
---|
| 93 | Deputy Registrar (Admissions) |
---|
| 94 | For: Registrar |
---|
| 95 | """ |
---|
| 96 | |
---|
| 97 | def render(self): |
---|
| 98 | students_utils = getUtility(IStudentsUtils) |
---|
[15887] | 99 | letterhead_path = os.path.join( |
---|
| 100 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
[15894] | 101 | topMargin=1.6 |
---|
[15887] | 102 | if self.context.student.current_mode.startswith('ug'): |
---|
| 103 | letterhead_path = None |
---|
[15890] | 104 | topMargin=1.5 |
---|
[15507] | 105 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 106 | self.context.student, omit_fields=self.omit_fields, |
---|
[15887] | 107 | letterhead_path=letterhead_path, |
---|
[15890] | 108 | topMargin=topMargin, |
---|
[15507] | 109 | post_text=self._post_text) |
---|
| 110 | |
---|
[8911] | 111 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 112 | """ Page to view an online payment ticket |
---|
| 113 | """ |
---|
| 114 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 115 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[15690] | 116 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
[8911] | 117 | form_fields[ |
---|
| 118 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 119 | form_fields[ |
---|
| 120 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 121 | |
---|
| 122 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 123 | """ Page to add an online payment ticket |
---|
| 124 | """ |
---|
| 125 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
[15668] | 126 | 'p_combi') |
---|
[8911] | 127 | |
---|
[15940] | 128 | class OnlinePaymentApproveView(OnlinePaymentApproveView): |
---|
| 129 | grok.require('waeup.manageStudent') |
---|
| 130 | |
---|
[13060] | 131 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 132 | """Deliver a PDF slip of the context. |
---|
| 133 | """ |
---|
| 134 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 135 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[15690] | 136 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
[8911] | 137 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9156] | 138 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 139 | |
---|
| 140 | class CustomStartClearancePage(StartClearancePage): |
---|
| 141 | |
---|
[9953] | 142 | @property |
---|
| 143 | def with_ac(self): |
---|
| 144 | mode = getattr(self.context, 'current_mode', None) |
---|
| 145 | if mode and mode.startswith('ug'): |
---|
| 146 | return True |
---|
| 147 | return False |
---|
[9156] | 148 | |
---|
[13060] | 149 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[10019] | 150 | """Deliver a PDF slip of the context. |
---|
| 151 | """ |
---|
| 152 | |
---|
| 153 | @property |
---|
| 154 | def form_fields(self): |
---|
| 155 | if self.context.is_postgrad: |
---|
| 156 | form_fields = grok.AutoFields( |
---|
| 157 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
| 158 | else: |
---|
| 159 | form_fields = grok.AutoFields( |
---|
| 160 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
| 161 | if not getattr(self.context, 'officer_comment'): |
---|
| 162 | form_fields = form_fields.omit('officer_comment') |
---|
| 163 | return form_fields |
---|
| 164 | |
---|
| 165 | @property |
---|
| 166 | def label(self): |
---|
| 167 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 168 | |
---|
| 169 | line0 = '' |
---|
| 170 | if self.context.student.current_mode.startswith('ug'): |
---|
| 171 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
| 172 | line1 = translate(_('Clearance Slip of'), |
---|
| 173 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 174 | + ' %s' % self.context.display_fullname |
---|
| 175 | return '%s%s' % (line0, line1) |
---|
| 176 | |
---|
| 177 | |
---|
[9181] | 178 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 179 | """ View to edit student clearance data by student |
---|
| 180 | """ |
---|
| 181 | |
---|
| 182 | def dataNotComplete(self): |
---|
[9190] | 183 | return False |
---|
| 184 | |
---|
[15717] | 185 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
[9190] | 186 | """ Page to add an online payment ticket |
---|
| 187 | """ |
---|
| 188 | buttonname = _('Create bed ticket') |
---|
| 189 | notice = '' |
---|
[14591] | 190 | with_ac = False |
---|
| 191 | |
---|
| 192 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 193 | """ Page to display student study levels |
---|
| 194 | """ |
---|
| 195 | grok.context(ICustomStudentStudyLevel) |
---|
| 196 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 197 | form_fields[ |
---|
| 198 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 199 | |
---|
| 200 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 201 | NigeriaExportPDFCourseRegistrationSlip): |
---|
| 202 | """Deliver a PDF slip of the context. |
---|
| 203 | """ |
---|
| 204 | grok.context(ICustomStudentStudyLevel) |
---|
[15304] | 205 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 206 | |
---|
| 207 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 208 | """ Page to manage the student payments. This manage form page is for |
---|
| 209 | both students and students officers. FCEOkene does not allow students |
---|
| 210 | to remove any payment ticket. |
---|
| 211 | """ |
---|
| 212 | @property |
---|
| 213 | def manage_payments_allowed(self): |
---|
| 214 | return checkPermission('waeup.manageStudent', self.context) |
---|