[8911] | 1 | ## $Id: browser.py 17566 2023-08-30 08:22:36Z 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 |
---|
[15977] | 24 | from waeup.kofa.interfaces import ADMITTED, VALIDATED, 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, |
---|
[15977] | 32 | OnlinePaymentApproveView, |
---|
| 33 | StudentBasePDFFormPage) |
---|
[8911] | 34 | from kofacustom.nigeria.students.browser import ( |
---|
| 35 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 36 | NigeriaOnlinePaymentAddFormPage, |
---|
[13060] | 37 | NigeriaExportPDFPaymentSlip, |
---|
[9190] | 38 | NigeriaStudentClearanceEditFormPage, |
---|
[14591] | 39 | NigeriaExportPDFClearanceSlip, |
---|
[15717] | 40 | NigeriaExportPDFCourseRegistrationSlip, |
---|
| 41 | NigeriaBedTicketAddPage, |
---|
[16366] | 42 | NigeriaAccommodationManageFormPage, |
---|
| 43 | NigeriaAccommodationDisplayFormPage, |
---|
[9190] | 44 | ) |
---|
[8911] | 45 | |
---|
[10019] | 46 | from waeup.fceokene.students.interfaces import ( |
---|
[14591] | 47 | ICustomStudentOnlinePayment, ICustomUGStudentClearance, |
---|
| 48 | ICustomStudentStudyLevel) |
---|
[8911] | 49 | |
---|
[13060] | 50 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
[9945] | 51 | """Deliver a PDF Admission slip. |
---|
| 52 | """ |
---|
| 53 | |
---|
| 54 | @property |
---|
| 55 | def label(self): |
---|
| 56 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 57 | line0 = '' |
---|
| 58 | if self.context.student.current_mode.startswith('ug'): |
---|
| 59 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
| 60 | line1 = translate(_('Admission Letter of'), |
---|
| 61 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 62 | + ' %s' % self.context.display_fullname |
---|
| 63 | return '%s%s' % (line0, line1) |
---|
| 64 | |
---|
[15507] | 65 | @property |
---|
| 66 | def _post_text(self): |
---|
| 67 | return """You should note the following as conditions for admission: |
---|
| 68 | |
---|
[17565] | 69 | 1. At the point of registration, you will be required to present the originals of your |
---|
| 70 | certificate(s), Jamb Original Result, a Birth Certificate or a Declaration of |
---|
| 71 | Age Certificate and Evidence of Citizenship Certificate. |
---|
[15690] | 72 | |
---|
[17565] | 73 | 2. Please note that the name by which you are hereby admitted and by which you will |
---|
| 74 | be registered is the one which will appear on any certificate that the |
---|
| 75 | Federal College of Education, Okene may issue to you on successful completion of |
---|
| 76 | your programme except there was a change of name by sworn affidavit or |
---|
| 77 | marriage certificate in addition to newspaper publication. |
---|
[15690] | 78 | |
---|
[17565] | 79 | 3. You are hereby informed that all fees must be paid at the beginning of the |
---|
| 80 | academic session. The current school fees can be obtained from the College website. |
---|
[15690] | 81 | |
---|
[17565] | 82 | 4. You will present at the time of registration the Medical Certificate of Fitness |
---|
| 83 | from the Federal College of Education, Okene Medical Centre. |
---|
[15690] | 84 | |
---|
[17565] | 85 | 5. Please, note that due to shortage of accommodations, students shall be given |
---|
| 86 | accommodations on first come, first serve basis. |
---|
[15690] | 87 | |
---|
[15509] | 88 | 6. The offer is not transferable to another session. |
---|
[15507] | 89 | |
---|
[17565] | 90 | 7. You will sign a declaration of good conduct except by deferment on your |
---|
| 91 | arrival at the College. |
---|
[15690] | 92 | |
---|
[17565] | 93 | Accept my congratulations. Yours faithfully |
---|
[15507] | 94 | |
---|
[17566] | 95 | Ajoge E, A |
---|
[15507] | 96 | Deputy Registrar (Admissions) |
---|
| 97 | For: Registrar |
---|
| 98 | """ |
---|
| 99 | |
---|
| 100 | def render(self): |
---|
| 101 | students_utils = getUtility(IStudentsUtils) |
---|
[15887] | 102 | letterhead_path = os.path.join( |
---|
| 103 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
[15894] | 104 | topMargin=1.6 |
---|
[15887] | 105 | if self.context.student.current_mode.startswith('ug'): |
---|
| 106 | letterhead_path = None |
---|
[15890] | 107 | topMargin=1.5 |
---|
[15507] | 108 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 109 | self.context.student, omit_fields=self.omit_fields, |
---|
[15887] | 110 | letterhead_path=letterhead_path, |
---|
[15890] | 111 | topMargin=topMargin, |
---|
[15507] | 112 | post_text=self._post_text) |
---|
| 113 | |
---|
[8911] | 114 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 115 | """ Page to view an online payment ticket |
---|
| 116 | """ |
---|
| 117 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 118 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[15690] | 119 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
[8911] | 120 | form_fields[ |
---|
| 121 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 122 | form_fields[ |
---|
| 123 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 124 | |
---|
| 125 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 126 | """ Page to add an online payment ticket |
---|
| 127 | """ |
---|
| 128 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
[15668] | 129 | 'p_combi') |
---|
[8911] | 130 | |
---|
[15940] | 131 | class OnlinePaymentApproveView(OnlinePaymentApproveView): |
---|
| 132 | grok.require('waeup.manageStudent') |
---|
| 133 | |
---|
[13060] | 134 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 135 | """Deliver a PDF slip of the context. |
---|
| 136 | """ |
---|
| 137 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 138 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[15690] | 139 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
[8911] | 140 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9156] | 141 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 142 | |
---|
| 143 | class CustomStartClearancePage(StartClearancePage): |
---|
| 144 | |
---|
[9953] | 145 | @property |
---|
| 146 | def with_ac(self): |
---|
| 147 | mode = getattr(self.context, 'current_mode', None) |
---|
| 148 | if mode and mode.startswith('ug'): |
---|
| 149 | return True |
---|
| 150 | return False |
---|
[9156] | 151 | |
---|
[13060] | 152 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[10019] | 153 | """Deliver a PDF slip of the context. |
---|
| 154 | """ |
---|
| 155 | |
---|
| 156 | @property |
---|
| 157 | def form_fields(self): |
---|
| 158 | if self.context.is_postgrad: |
---|
| 159 | form_fields = grok.AutoFields( |
---|
| 160 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
| 161 | else: |
---|
| 162 | form_fields = grok.AutoFields( |
---|
| 163 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
| 164 | if not getattr(self.context, 'officer_comment'): |
---|
| 165 | form_fields = form_fields.omit('officer_comment') |
---|
| 166 | return form_fields |
---|
| 167 | |
---|
| 168 | @property |
---|
| 169 | def label(self): |
---|
| 170 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 171 | |
---|
| 172 | line0 = '' |
---|
| 173 | if self.context.student.current_mode.startswith('ug'): |
---|
| 174 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
| 175 | line1 = translate(_('Clearance Slip of'), |
---|
| 176 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 177 | + ' %s' % self.context.display_fullname |
---|
| 178 | return '%s%s' % (line0, line1) |
---|
| 179 | |
---|
| 180 | |
---|
[9181] | 181 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 182 | """ View to edit student clearance data by student |
---|
| 183 | """ |
---|
| 184 | |
---|
| 185 | def dataNotComplete(self): |
---|
[9190] | 186 | return False |
---|
| 187 | |
---|
[15717] | 188 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
[9190] | 189 | """ Page to add an online payment ticket |
---|
| 190 | """ |
---|
| 191 | buttonname = _('Create bed ticket') |
---|
| 192 | notice = '' |
---|
[14591] | 193 | with_ac = False |
---|
[16366] | 194 | with_bedselection = True |
---|
[14591] | 195 | |
---|
| 196 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 197 | """ Page to display student study levels |
---|
| 198 | """ |
---|
| 199 | grok.context(ICustomStudentStudyLevel) |
---|
| 200 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 201 | form_fields[ |
---|
| 202 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 203 | |
---|
| 204 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 205 | NigeriaExportPDFCourseRegistrationSlip): |
---|
| 206 | """Deliver a PDF slip of the context. |
---|
| 207 | """ |
---|
| 208 | grok.context(ICustomStudentStudyLevel) |
---|
[15304] | 209 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 210 | |
---|
[15989] | 211 | class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip): |
---|
[15977] | 212 | """Deliver a PDF slip of the context. |
---|
| 213 | """ |
---|
[15989] | 214 | grok.name('examination_clearance_slip_1.pdf') |
---|
[15982] | 215 | form_fields = None |
---|
| 216 | omit_fields = ( |
---|
| 217 | 'password', 'suspended', 'phone', 'date_of_birth', |
---|
| 218 | 'parents_email', 'current_mode', 'entry_session', |
---|
| 219 | 'adm_code', 'sex', 'suspended_comment', |
---|
| 220 | 'flash_notice') |
---|
[15989] | 221 | semester = 1 |
---|
| 222 | tabletitle = ['', '', ''] |
---|
[15982] | 223 | |
---|
[15977] | 224 | @property |
---|
| 225 | def label(self): |
---|
[15989] | 226 | return '%s First Semester Examination Clearance' % self.context.level_session |
---|
[15977] | 227 | |
---|
[15982] | 228 | @property |
---|
| 229 | def title(self): |
---|
| 230 | return '' |
---|
| 231 | |
---|
[15977] | 232 | def update(self): |
---|
| 233 | if self.context.student.state != VALIDATED \ |
---|
| 234 | or self.context.student.current_level != self.context.level: |
---|
| 235 | self.flash(_('Forbidden'), type="warning") |
---|
| 236 | self.redirect(self.url(self.context)) |
---|
| 237 | |
---|
| 238 | def render(self): |
---|
| 239 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 240 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
| 241 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 242 | self.request, self.omit_fields) |
---|
| 243 | students_utils = getUtility(IStudentsUtils) |
---|
| 244 | |
---|
| 245 | tabledata = [] |
---|
| 246 | tableheader = [] |
---|
| 247 | for i in range(1,7): |
---|
| 248 | tabledata.append(sorted( |
---|
[15989] | 249 | [value for value in self.context.values() if i == self.semester == value.semester], |
---|
| 250 | key=lambda value: value.code)) |
---|
[15977] | 251 | tableheader.append([(Code,'code', 2.5), |
---|
[15989] | 252 | ('Invigilator\'s Name','inv', 8), |
---|
[15993] | 253 | ('Signature and Date','sig', 7), |
---|
[15977] | 254 | ]) |
---|
| 255 | return students_utils.renderPDF( |
---|
[15989] | 256 | self, 'examination_clearance_slip_%s.pdf' % self.semester, |
---|
[15977] | 257 | self.context.student, studentview, |
---|
| 258 | tableheader=tableheader, |
---|
| 259 | tabledata=tabledata, |
---|
[15983] | 260 | omit_fields=self.omit_fields, |
---|
[15989] | 261 | topMargin=1.3 |
---|
[15977] | 262 | ) |
---|
| 263 | |
---|
[15989] | 264 | class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1): |
---|
| 265 | """Deliver a PDF slip of the context. |
---|
| 266 | """ |
---|
| 267 | grok.name('examination_clearance_slip_2.pdf') |
---|
| 268 | semester = 2 |
---|
[15977] | 269 | |
---|
[15989] | 270 | @property |
---|
| 271 | def label(self): |
---|
| 272 | return '%s Second Semester Examination Clearance' % self.context.level_session |
---|
| 273 | |
---|
[15304] | 274 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 275 | """ Page to manage the student payments. This manage form page is for |
---|
| 276 | both students and students officers. FCEOkene does not allow students |
---|
| 277 | to remove any payment ticket. |
---|
| 278 | """ |
---|
| 279 | @property |
---|
| 280 | def manage_payments_allowed(self): |
---|
[16366] | 281 | return checkPermission('waeup.manageStudent', self.context) |
---|
| 282 | |
---|
| 283 | class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): |
---|
| 284 | """ Page to view bed tickets. |
---|
| 285 | """ |
---|
| 286 | with_hostel_selection = True |
---|
| 287 | |
---|
| 288 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
| 289 | """ Page to manage bed tickets. |
---|
| 290 | This manage form page is for both students and students officers. |
---|
| 291 | """ |
---|
| 292 | with_hostel_selection = True |
---|