| 1 | ## $Id: browser.py 18268 2026-05-20 08:35:42Z 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 |
|---|
| 19 | import os |
|---|
| 20 | import textwrap |
|---|
| 21 | from zope.i18n import translate |
|---|
| 22 | from zope.component import getUtility, queryUtility |
|---|
| 23 | from zope.catalog.interfaces import ICatalog |
|---|
| 24 | from zope.security import checkPermission |
|---|
| 25 | from hurry.workflow.interfaces import IWorkflowInfo |
|---|
| 26 | from waeup.kofa.interfaces import ADMITTED, VALIDATED, IKofaUtils |
|---|
| 27 | from waeup.kofa.interfaces import MessageFactory as _ |
|---|
| 28 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
|---|
| 29 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
|---|
| 30 | from waeup.kofa.students.browser import ( |
|---|
| 31 | StartClearancePage, |
|---|
| 32 | ExportPDFAdmissionSlip, |
|---|
| 33 | PaymentsManageFormPage, |
|---|
| 34 | OnlinePaymentApproveView, |
|---|
| 35 | CourseTicketDisplayFormPage, |
|---|
| 36 | CourseTicketManageFormPage, |
|---|
| 37 | StudentBasePDFFormPage, |
|---|
| 38 | StudyLevelDisplayFormPage, |
|---|
| 39 | StudyLevelManageFormPage, |
|---|
| 40 | StudyLevelEditFormPage, |
|---|
| 41 | ExportAttendanceSlip) |
|---|
| 42 | from kofacustom.nigeria.students.browser import ( |
|---|
| 43 | NigeriaOnlinePaymentDisplayFormPage, |
|---|
| 44 | NigeriaOnlinePaymentAddFormPage, |
|---|
| 45 | NigeriaExportPDFPaymentSlip, |
|---|
| 46 | NigeriaStudentClearanceDisplayFormPage, |
|---|
| 47 | NigeriaStudentClearanceEditFormPage, |
|---|
| 48 | NigeriaStudentClearanceManageFormPage, |
|---|
| 49 | NigeriaExportPDFClearanceSlip, |
|---|
| 50 | NigeriaExportPDFCourseRegistrationSlip, |
|---|
| 51 | NigeriaBedTicketAddPage, |
|---|
| 52 | NigeriaAccommodationManageFormPage, |
|---|
| 53 | NigeriaAccommodationDisplayFormPage, |
|---|
| 54 | ) |
|---|
| 55 | |
|---|
| 56 | from waeup.fceokene.students.interfaces import ( |
|---|
| 57 | ICustomStudentOnlinePayment, |
|---|
| 58 | ICustomUGStudentClearance, |
|---|
| 59 | ICustomPGStudentClearance, |
|---|
| 60 | ICustomStudentStudyLevel) |
|---|
| 61 | |
|---|
| 62 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
|---|
| 63 | """Deliver a PDF Admission slip. |
|---|
| 64 | """ |
|---|
| 65 | |
|---|
| 66 | @property |
|---|
| 67 | def label(self): |
|---|
| 68 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 69 | line0 = '' |
|---|
| 70 | if self.context.student.current_mode.startswith('ug') and self.context.student.faccode != 'SUP': |
|---|
| 71 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
|---|
| 72 | line1 = translate(_('Admission Letter of'), |
|---|
| 73 | 'waeup.kofa', target_language=portal_language) \ |
|---|
| 74 | + ' %s' % self.context.display_fullname |
|---|
| 75 | return '%s%s' % (line0, line1) |
|---|
| 76 | |
|---|
| 77 | @property |
|---|
| 78 | def _post_text(self): |
|---|
| 79 | return """You should note the following as conditions for admission: |
|---|
| 80 | |
|---|
| 81 | 1. At the point of registration, you will be required to present the originals of your |
|---|
| 82 | certificate(s), Jamb Original Result, a Birth Certificate or a Declaration of |
|---|
| 83 | Age Certificate and Evidence of Citizenship Certificate. |
|---|
| 84 | |
|---|
| 85 | 2. Please note that the name by which you are hereby admitted and by which you will |
|---|
| 86 | be registered is the one which will appear on any certificate that the |
|---|
| 87 | Federal College of Education, Okene may issue to you on successful completion of |
|---|
| 88 | your programme except there was a change of name by sworn affidavit or |
|---|
| 89 | marriage certificate in addition to newspaper publication. |
|---|
| 90 | |
|---|
| 91 | 3. You are hereby informed that all fees must be paid at the beginning of the |
|---|
| 92 | academic session. The current school fees can be obtained from the College website. |
|---|
| 93 | |
|---|
| 94 | 4. You will present at the time of registration the Medical Certificate of Fitness |
|---|
| 95 | from the Federal College of Education, Okene Medical Centre. |
|---|
| 96 | |
|---|
| 97 | 5. Students shall be given accommodations on first come, first serve basis. |
|---|
| 98 | |
|---|
| 99 | 6. The offer is not transferable to another session. |
|---|
| 100 | |
|---|
| 101 | 7. You will sign a declaration of good conduct except by deferment on your |
|---|
| 102 | arrival at the College. |
|---|
| 103 | |
|---|
| 104 | Accept my congratulations. Yours faithfully |
|---|
| 105 | |
|---|
| 106 | Ajoge E, A |
|---|
| 107 | Deputy Registrar (Admissions) |
|---|
| 108 | For: Registrar |
|---|
| 109 | """ |
|---|
| 110 | |
|---|
| 111 | def render(self): |
|---|
| 112 | students_utils = getUtility(IStudentsUtils) |
|---|
| 113 | letterhead_path = os.path.join( |
|---|
| 114 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
|---|
| 115 | topMargin=1.8 |
|---|
| 116 | if self.context.student.current_mode.startswith('ug') and self.context.student.faccode != 'SUP': |
|---|
| 117 | letterhead_path = None |
|---|
| 118 | topMargin=1.3 |
|---|
| 119 | return students_utils.renderPDFAdmissionLetter(self, |
|---|
| 120 | self.context.student, omit_fields=self.omit_fields, |
|---|
| 121 | letterhead_path=letterhead_path, |
|---|
| 122 | topMargin=topMargin, |
|---|
| 123 | post_text=self._post_text) |
|---|
| 124 | |
|---|
| 125 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
|---|
| 126 | """ Page to view an online payment ticket |
|---|
| 127 | """ |
|---|
| 128 | grok.context(ICustomStudentOnlinePayment) |
|---|
| 129 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
|---|
| 130 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
|---|
| 131 | form_fields[ |
|---|
| 132 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 133 | form_fields[ |
|---|
| 134 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 135 | |
|---|
| 136 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
|---|
| 137 | """ Page to add an online payment ticket |
|---|
| 138 | """ |
|---|
| 139 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
|---|
| 140 | 'p_combi') |
|---|
| 141 | |
|---|
| 142 | class OnlinePaymentApproveView(OnlinePaymentApproveView): |
|---|
| 143 | grok.require('waeup.manageStudent') |
|---|
| 144 | |
|---|
| 145 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
|---|
| 146 | """Deliver a PDF slip of the context. |
|---|
| 147 | """ |
|---|
| 148 | grok.context(ICustomStudentOnlinePayment) |
|---|
| 149 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
|---|
| 150 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
|---|
| 151 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 152 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 153 | |
|---|
| 154 | class CustomStartClearancePage(StartClearancePage): |
|---|
| 155 | |
|---|
| 156 | @property |
|---|
| 157 | def with_ac(self): |
|---|
| 158 | mode = getattr(self.context, 'current_mode', None) |
|---|
| 159 | if mode and mode.startswith('ug'): |
|---|
| 160 | return True |
|---|
| 161 | return False |
|---|
| 162 | |
|---|
| 163 | class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage): |
|---|
| 164 | """ Page to display student clearance data |
|---|
| 165 | """ |
|---|
| 166 | |
|---|
| 167 | @property |
|---|
| 168 | def form_fields(self): |
|---|
| 169 | if self.context.is_postgrad: |
|---|
| 170 | form_fields = grok.AutoFields( |
|---|
| 171 | ICustomPGStudentClearance).omit('clearance_locked') |
|---|
| 172 | else: |
|---|
| 173 | form_fields = grok.AutoFields( |
|---|
| 174 | ICustomUGStudentClearance).omit('clearance_locked') |
|---|
| 175 | if not getattr(self.context, 'officer_comment'): |
|---|
| 176 | form_fields = form_fields.omit('officer_comment') |
|---|
| 177 | else: |
|---|
| 178 | form_fields['officer_comment'].custom_widget = BytesDisplayWidget |
|---|
| 179 | return form_fields |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage): |
|---|
| 183 | """ Page to edit student clearance data |
|---|
| 184 | """ |
|---|
| 185 | |
|---|
| 186 | @property |
|---|
| 187 | def form_fields(self): |
|---|
| 188 | if self.context.is_postgrad: |
|---|
| 189 | form_fields = grok.AutoFields( |
|---|
| 190 | ICustomPGStudentClearance).omit('clr_code') |
|---|
| 191 | else: |
|---|
| 192 | form_fields = grok.AutoFields( |
|---|
| 193 | ICustomUGStudentClearance).omit('clr_code') |
|---|
| 194 | return form_fields |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
|---|
| 198 | """Deliver a PDF slip of the context. |
|---|
| 199 | """ |
|---|
| 200 | |
|---|
| 201 | @property |
|---|
| 202 | def form_fields(self): |
|---|
| 203 | if self.context.is_postgrad: |
|---|
| 204 | form_fields = grok.AutoFields( |
|---|
| 205 | ICustomPGStudentClearance).omit('clearance_locked') |
|---|
| 206 | else: |
|---|
| 207 | form_fields = grok.AutoFields( |
|---|
| 208 | ICustomUGStudentClearance).omit('clearance_locked') |
|---|
| 209 | if not getattr(self.context, 'officer_comment'): |
|---|
| 210 | form_fields = form_fields.omit('officer_comment') |
|---|
| 211 | return form_fields |
|---|
| 212 | |
|---|
| 213 | @property |
|---|
| 214 | def label(self): |
|---|
| 215 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 216 | |
|---|
| 217 | line0 = '' |
|---|
| 218 | if self.context.student.current_mode.startswith('ug'): |
|---|
| 219 | line0 = 'Directorate of Undergraduate Programme\n' |
|---|
| 220 | line1 = translate(_('Clearance Slip of'), |
|---|
| 221 | 'waeup.kofa', target_language=portal_language) \ |
|---|
| 222 | + ' %s' % self.context.display_fullname |
|---|
| 223 | return '%s%s' % (line0, line1) |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
|---|
| 227 | """ View to edit student clearance data by student |
|---|
| 228 | """ |
|---|
| 229 | |
|---|
| 230 | def dataNotComplete(self): |
|---|
| 231 | return False |
|---|
| 232 | |
|---|
| 233 | @property |
|---|
| 234 | def form_fields(self): |
|---|
| 235 | if self.context.is_postgrad: |
|---|
| 236 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( |
|---|
| 237 | 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment', |
|---|
| 238 | 'physical_clearance_date') |
|---|
| 239 | else: |
|---|
| 240 | form_fields = grok.AutoFields(ICustomUGStudentClearance).omit( |
|---|
| 241 | 'clearance_locked', 'clr_code', 'officer_comment', |
|---|
| 242 | 'physical_clearance_date') |
|---|
| 243 | return form_fields |
|---|
| 244 | |
|---|
| 245 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
|---|
| 246 | """ Page to add an online payment ticket |
|---|
| 247 | """ |
|---|
| 248 | buttonname = _('Create bed ticket') |
|---|
| 249 | notice = '' |
|---|
| 250 | with_ac = False |
|---|
| 251 | with_bedselection = True |
|---|
| 252 | |
|---|
| 253 | class CustomExportPDFCourseRegistrationSlip( |
|---|
| 254 | NigeriaExportPDFCourseRegistrationSlip): |
|---|
| 255 | """Deliver a PDF slip of the context. |
|---|
| 256 | """ |
|---|
| 257 | grok.context(ICustomStudentStudyLevel) |
|---|
| 258 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
|---|
| 259 | 'level', 'level_verdict', 'validated_by', 'transcript_remark', 'gpa') |
|---|
| 260 | form_fields[ |
|---|
| 261 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 262 | omit_fields = ('password', 'suspended', 'suspended_comment', |
|---|
| 263 | 'phone', 'adm_code', 'sex', 'email', 'date_of_birth', 'current_level', |
|---|
| 264 | 'flash_notice', 'parents_email', 'entry_session', 'password_updated') |
|---|
| 265 | |
|---|
| 266 | @property |
|---|
| 267 | def tabletitle(self): |
|---|
| 268 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 269 | tabletitle = [] |
|---|
| 270 | tabletitle.append('1st Semester Courses') |
|---|
| 271 | tabletitle.append('_PB_2nd Semester Courses') |
|---|
| 272 | tabletitle.append('Level Courses') |
|---|
| 273 | return tabletitle |
|---|
| 274 | |
|---|
| 275 | def render(self): |
|---|
| 276 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 277 | Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) |
|---|
| 278 | Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) |
|---|
| 279 | Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 280 | Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language) |
|---|
| 281 | Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 282 | #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 283 | Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) |
|---|
| 284 | Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) |
|---|
| 285 | CC = translate(_('Cat.'), target_language=portal_language) |
|---|
| 286 | studentview = StudentBasePDFFormPage(self.context.student, |
|---|
| 287 | self.request, self.omit_fields) |
|---|
| 288 | students_utils = getUtility(IStudentsUtils) |
|---|
| 289 | |
|---|
| 290 | tabledata = [] |
|---|
| 291 | tableheader = [] |
|---|
| 292 | for i in range(1,7): |
|---|
| 293 | tabledata.append(sorted( |
|---|
| 294 | [value for value in self.context.values() if value.semester == i], |
|---|
| 295 | key=lambda value: str(value.semester) + value.code)) |
|---|
| 296 | tableheader.append([(Code,'code', 2.5), |
|---|
| 297 | (Title,'title', 7), |
|---|
| 298 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
|---|
| 299 | (Cred, 'credits', 1.5), |
|---|
| 300 | (CC, 'course_category', 1.5), |
|---|
| 301 | #(Mand, 'mandatory', 1.5), |
|---|
| 302 | #(Score, 'score', 1.5), |
|---|
| 303 | #(Grade, 'grade', 1.5), |
|---|
| 304 | #('Auto', 'automatic', 1.5) |
|---|
| 305 | ]) |
|---|
| 306 | return students_utils.renderPDF( |
|---|
| 307 | self, 'course_registration_slip_%s.pdf' % self.context.student.student_id, |
|---|
| 308 | self.context.student, studentview, |
|---|
| 309 | tableheader=tableheader, |
|---|
| 310 | tabledata=tabledata, |
|---|
| 311 | omit_fields=self.omit_fields, |
|---|
| 312 | signatures=self._signatures(), |
|---|
| 313 | sigs_in_footer=self._sigsInFooter(), |
|---|
| 314 | ) |
|---|
| 315 | |
|---|
| 316 | class ExportPDFCourseResultSlip(CustomExportPDFCourseRegistrationSlip): |
|---|
| 317 | """Deliver a PDF slip of the context. |
|---|
| 318 | """ |
|---|
| 319 | |
|---|
| 320 | grok.name('course_result_slip.pdf') |
|---|
| 321 | |
|---|
| 322 | @property |
|---|
| 323 | def label(self): |
|---|
| 324 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 325 | lang = self.request.cookies.get('kofa.language', portal_language) |
|---|
| 326 | level_title = translate(self.context.level_title, 'waeup.kofa', |
|---|
| 327 | target_language=lang) |
|---|
| 328 | return translate(_('Course Result Slip'), |
|---|
| 329 | 'waeup.uniben', target_language=portal_language) \ |
|---|
| 330 | + ' %s' % level_title |
|---|
| 331 | |
|---|
| 332 | def render(self): |
|---|
| 333 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 334 | Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language) |
|---|
| 335 | Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language) |
|---|
| 336 | Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 337 | Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language) |
|---|
| 338 | Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 339 | #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language) |
|---|
| 340 | Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language) |
|---|
| 341 | Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language) |
|---|
| 342 | CC = translate(_('Cat.'), target_language=portal_language) |
|---|
| 343 | studentview = StudentBasePDFFormPage(self.context.student, |
|---|
| 344 | self.request, self.omit_fields) |
|---|
| 345 | students_utils = getUtility(IStudentsUtils) |
|---|
| 346 | |
|---|
| 347 | tabledata = [] |
|---|
| 348 | tableheader = [] |
|---|
| 349 | for i in range(1,7): |
|---|
| 350 | tabledata.append(sorted( |
|---|
| 351 | [value for value in self.context.values() if value.semester == i], |
|---|
| 352 | key=lambda value: str(value.semester) + value.code)) |
|---|
| 353 | tableheader.append([(Code,'code', 2.5), |
|---|
| 354 | (Title,'title', 5), |
|---|
| 355 | (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5), |
|---|
| 356 | (Cred, 'credits', 1.5), |
|---|
| 357 | (CC, 'course_category', 1.5), |
|---|
| 358 | #(Mand, 'mandatory', 1.5), |
|---|
| 359 | (Score, 'score', 1.5), |
|---|
| 360 | (Grade, 'grade', 1.5), |
|---|
| 361 | #('Auto', 'automatic', 1.5) |
|---|
| 362 | ]) |
|---|
| 363 | return students_utils.renderPDF( |
|---|
| 364 | self, 'course_result_slip_%s.pdf' % self.context.student.student_id, |
|---|
| 365 | self.context.student, studentview, |
|---|
| 366 | tableheader=tableheader, |
|---|
| 367 | tabledata=tabledata, |
|---|
| 368 | omit_fields=self.omit_fields, |
|---|
| 369 | signatures=self._signatures(), |
|---|
| 370 | sigs_in_footer=self._sigsInFooter(), |
|---|
| 371 | ) |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip): |
|---|
| 375 | """Deliver a PDF slip of the context. |
|---|
| 376 | """ |
|---|
| 377 | grok.name('examination_clearance_slip_1.pdf') |
|---|
| 378 | form_fields = None |
|---|
| 379 | omit_fields = ( |
|---|
| 380 | 'password', 'suspended', 'phone', 'date_of_birth', |
|---|
| 381 | 'parents_email', 'current_mode', 'entry_session', |
|---|
| 382 | 'adm_code', 'sex', 'suspended_comment', |
|---|
| 383 | 'flash_notice', 'password_updated', 'current_level') |
|---|
| 384 | semester = 1 |
|---|
| 385 | tabletitle = ['', '', ''] |
|---|
| 386 | |
|---|
| 387 | @property |
|---|
| 388 | def label(self): |
|---|
| 389 | return '%s First Semester Examination Clearance' % self.context.level_session |
|---|
| 390 | |
|---|
| 391 | @property |
|---|
| 392 | def title(self): |
|---|
| 393 | return '' |
|---|
| 394 | |
|---|
| 395 | def update(self): |
|---|
| 396 | if self.context.student.state != VALIDATED \ |
|---|
| 397 | or self.context.student.current_level != self.context.level: |
|---|
| 398 | self.flash(_('Forbidden'), type="warning") |
|---|
| 399 | self.redirect(self.url(self.context)) |
|---|
| 400 | |
|---|
| 401 | def render(self): |
|---|
| 402 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
|---|
| 403 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
|---|
| 404 | studentview = StudentBasePDFFormPage(self.context.student, |
|---|
| 405 | self.request, self.omit_fields) |
|---|
| 406 | students_utils = getUtility(IStudentsUtils) |
|---|
| 407 | |
|---|
| 408 | tabledata = [] |
|---|
| 409 | tableheader = [] |
|---|
| 410 | for i in range(1,7): |
|---|
| 411 | tabledata.append(sorted( |
|---|
| 412 | [value for value in self.context.values() if i == self.semester == value.semester], |
|---|
| 413 | key=lambda value: value.code)) |
|---|
| 414 | tableheader.append([(Code,'code', 2.5), |
|---|
| 415 | ('Invigilator\'s Name','inv', 8), |
|---|
| 416 | ('Signature and Date','sig', 7), |
|---|
| 417 | ]) |
|---|
| 418 | return students_utils.renderPDF( |
|---|
| 419 | self, 'examination_clearance_slip_%s.pdf' % self.semester, |
|---|
| 420 | self.context.student, studentview, |
|---|
| 421 | tableheader=tableheader, |
|---|
| 422 | tabledata=tabledata, |
|---|
| 423 | omit_fields=self.omit_fields, |
|---|
| 424 | topMargin=1.3 |
|---|
| 425 | ) |
|---|
| 426 | |
|---|
| 427 | class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1): |
|---|
| 428 | """Deliver a PDF slip of the context. |
|---|
| 429 | """ |
|---|
| 430 | grok.name('examination_clearance_slip_2.pdf') |
|---|
| 431 | semester = 2 |
|---|
| 432 | |
|---|
| 433 | @property |
|---|
| 434 | def label(self): |
|---|
| 435 | return '%s Second Semester Examination Clearance' % self.context.level_session |
|---|
| 436 | |
|---|
| 437 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
|---|
| 438 | """ Page to display student study levels |
|---|
| 439 | """ |
|---|
| 440 | grok.context(ICustomStudentStudyLevel) |
|---|
| 441 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
|---|
| 442 | form_fields[ |
|---|
| 443 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
|---|
| 444 | |
|---|
| 445 | class CustomStudyLevelManageFormPage(StudyLevelManageFormPage): |
|---|
| 446 | """ Page to edit the student study level data |
|---|
| 447 | """ |
|---|
| 448 | |
|---|
| 449 | class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): |
|---|
| 450 | """ Page to edit the student study level data by students |
|---|
| 451 | """ |
|---|
| 452 | |
|---|
| 453 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
|---|
| 454 | """ Page to display course tickets |
|---|
| 455 | """ |
|---|
| 456 | form_fields = grok.AutoFields(ICourseTicket).omit( |
|---|
| 457 | 'ticket_session') |
|---|
| 458 | |
|---|
| 459 | class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): |
|---|
| 460 | """ Page to manage course tickets |
|---|
| 461 | """ |
|---|
| 462 | form_fields = grok.AutoFields(ICourseTicket) |
|---|
| 463 | form_fields['title'].for_display = True |
|---|
| 464 | form_fields['fcode'].for_display = True |
|---|
| 465 | form_fields['dcode'].for_display = True |
|---|
| 466 | form_fields['semester'].for_display = True |
|---|
| 467 | form_fields['passmark'].for_display = True |
|---|
| 468 | form_fields['credits'].for_display = True |
|---|
| 469 | form_fields['mandatory'].for_display = False |
|---|
| 470 | form_fields['automatic'].for_display = True |
|---|
| 471 | form_fields['carry_over'].for_display = True |
|---|
| 472 | form_fields['ticket_session'].for_display = True |
|---|
| 473 | |
|---|
| 474 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
|---|
| 475 | """ Page to manage the student payments. This manage form page is for |
|---|
| 476 | both students and students officers. FCEOkene does not allow students |
|---|
| 477 | to remove any payment ticket. |
|---|
| 478 | """ |
|---|
| 479 | @property |
|---|
| 480 | def manage_payments_allowed(self): |
|---|
| 481 | return checkPermission('waeup.manageStudent', self.context) |
|---|
| 482 | |
|---|
| 483 | class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): |
|---|
| 484 | """ Page to view bed tickets. |
|---|
| 485 | """ |
|---|
| 486 | with_hostel_selection = True |
|---|
| 487 | |
|---|
| 488 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
|---|
| 489 | """ Page to manage bed tickets. |
|---|
| 490 | This manage form page is for both students and students officers. |
|---|
| 491 | """ |
|---|
| 492 | with_hostel_selection = True |
|---|
| 493 | |
|---|
| 494 | class CustomExportAttendanceSlip(ExportAttendanceSlip): |
|---|
| 495 | """Deliver a PDF slip of course tickets in attendance sheet format. |
|---|
| 496 | """ |
|---|
| 497 | |
|---|
| 498 | def data(self, session): |
|---|
| 499 | cat = queryUtility(ICatalog, name='coursetickets_catalog') |
|---|
| 500 | # Attention: Also tickets of previous studycourses are found |
|---|
| 501 | coursetickets = cat.searchResults( |
|---|
| 502 | session=(session, session), |
|---|
| 503 | code=(self.context.code, self.context.code) |
|---|
| 504 | ) |
|---|
| 505 | header = [[_('S/N'), |
|---|
| 506 | _('Matric No.'), |
|---|
| 507 | _('Name'), |
|---|
| 508 | _('Level'), |
|---|
| 509 | #_('Course of\nStudies'), |
|---|
| 510 | _('Booklet No.'), |
|---|
| 511 | #_('Venue'), |
|---|
| 512 | #_('Time'), |
|---|
| 513 | _('Sign in'), |
|---|
| 514 | _('Sign out'), |
|---|
| 515 | ],] |
|---|
| 516 | tickets = [] |
|---|
| 517 | sn = 1 |
|---|
| 518 | ctlist = sorted(list(coursetickets), |
|---|
| 519 | key=lambda value: str(value.student.faccode) + |
|---|
| 520 | str(value.student.depcode) + |
|---|
| 521 | str(value.student.certcode) + |
|---|
| 522 | str(value.student.matric_number)) |
|---|
| 523 | # In AAUE only editable appear on the attendance sheet. Hopefully |
|---|
| 524 | # this holds for other universities too. |
|---|
| 525 | editable_tickets = [ticket for ticket in ctlist |
|---|
| 526 | if ticket.editable_by_lecturer] |
|---|
| 527 | for ticket in editable_tickets: |
|---|
| 528 | name = textwrap.fill(ticket.student.display_fullname, 30) |
|---|
| 529 | row = [sn, |
|---|
| 530 | ticket.student.matric_number, |
|---|
| 531 | name, |
|---|
| 532 | ticket.level, |
|---|
| 533 | #ticket.student.certcode, |
|---|
| 534 | 24 * ' ', |
|---|
| 535 | #10 * ' ', |
|---|
| 536 | #10 * ' ', |
|---|
| 537 | 13 * ' ', |
|---|
| 538 | 13 * ' ', |
|---|
| 539 | ] |
|---|
| 540 | tickets.append(row) |
|---|
| 541 | sn += 1 |
|---|
| 542 | return header + tickets, None |
|---|