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