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