[16639] | 1 | ## $Id: browser.py 17379 2023-04-14 11:57:48Z henrik $ |
---|
[15614] | 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 |
---|
[16695] | 19 | import os |
---|
[15614] | 20 | from zope.i18n import translate |
---|
| 21 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
| 22 | from zope.component import getUtility |
---|
[16715] | 23 | from zope.security import checkPermission |
---|
[15614] | 24 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
| 25 | from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils |
---|
| 26 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
| 27 | from waeup.kofa.browser.layout import KofaEditFormPage |
---|
| 28 | from waeup.kofa.browser.layout import action, jsaction |
---|
| 29 | from waeup.kofa.students.browser import ( |
---|
| 30 | StudyLevelEditFormPage, StudyLevelDisplayFormPage, |
---|
| 31 | StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, |
---|
[17345] | 32 | CourseTicketDisplayFormPage, |
---|
| 33 | CourseTicketManageFormPage, |
---|
| 34 | StudyLevelDisplayFormPage, |
---|
| 35 | StudentTriggerTransitionFormPage, |
---|
[16715] | 36 | ExportPDFAdmissionSlip, StartClearancePage, PaymentsManageFormPage, |
---|
[16796] | 37 | BalancePaymentAddFormPage, msave, emit_lock_message) |
---|
[15614] | 38 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
---|
| 39 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
| 40 | from kofacustom.nigeria.students.browser import ( |
---|
| 41 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 42 | NigeriaStudentBaseManageFormPage, |
---|
| 43 | NigeriaStudentClearanceEditFormPage, |
---|
| 44 | NigeriaOnlinePaymentAddFormPage, |
---|
| 45 | NigeriaExportPDFPaymentSlip, |
---|
| 46 | NigeriaExportPDFClearanceSlip, |
---|
[16712] | 47 | NigeriaExportPDFPaymentSlip, |
---|
[16846] | 48 | NigeriaBedTicketAddPage, |
---|
[15614] | 49 | ) |
---|
| 50 | |
---|
[16615] | 51 | from kofacustom.edocons.students.interfaces import ( |
---|
[15614] | 52 | ICustomStudentOnlinePayment, ICustomStudentStudyCourse, |
---|
[17345] | 53 | ICustomStudentStudyLevel, ICustomCourseTicket) |
---|
[16615] | 54 | from kofacustom.edocons.interfaces import MessageFactory as _ |
---|
[15614] | 55 | |
---|
[17345] | 56 | def translated_values(view): |
---|
| 57 | """Translate course ticket attribute values to be displayed on |
---|
| 58 | studylevel pages. |
---|
| 59 | """ |
---|
| 60 | lang = view.request.cookies.get('kofa.language') |
---|
| 61 | for value in view.context.values(): |
---|
| 62 | # We have to unghostify (according to Tres Seaver) the __dict__ |
---|
| 63 | # by activating the object, otherwise value_dict will be empty |
---|
| 64 | # when calling the first time. |
---|
| 65 | value._p_activate() |
---|
| 66 | value_dict = dict([i for i in value.__dict__.items()]) |
---|
| 67 | value_dict['url'] = view.url(value) |
---|
| 68 | value_dict['removable_by_student'] = value.removable_by_student |
---|
| 69 | value_dict['mandatory'] = translate(str(value.mandatory), 'zope', |
---|
| 70 | target_language=lang) |
---|
| 71 | value_dict['carry_over'] = translate(str(value.carry_over), 'zope', |
---|
| 72 | target_language=lang) |
---|
| 73 | value_dict['outstanding'] = translate(str(value.outstanding), 'zope', |
---|
| 74 | target_language=lang) |
---|
| 75 | value_dict['automatic'] = translate(str(value.automatic), 'zope', |
---|
| 76 | target_language=lang) |
---|
| 77 | value_dict['grade'] = value.grade |
---|
| 78 | value_dict['weight'] = value.weight |
---|
| 79 | value_dict['course_category'] = value.course_category |
---|
| 80 | value_dict['total_score'] = value.total_score |
---|
| 81 | semester_dict = getUtility(IKofaUtils).SEMESTER_DICT |
---|
| 82 | value_dict['semester'] = semester_dict[ |
---|
| 83 | value.semester].replace('mester', 'm.') |
---|
| 84 | # ECNS specific |
---|
| 85 | value_dict['carryover_score'] = value.carryover_score |
---|
| 86 | yield value_dict |
---|
| 87 | |
---|
[16699] | 88 | class CustomStartClearancePage(StartClearancePage): |
---|
| 89 | with_ac = False |
---|
| 90 | |
---|
[16695] | 91 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
| 92 | """Deliver a PDF Admission slip. |
---|
| 93 | """ |
---|
| 94 | |
---|
| 95 | omit_fields = ('date_of_birth', 'current_level', 'current_mode', |
---|
| 96 | 'certificate', 'faculty') |
---|
| 97 | #form_fields = grok.AutoFields(IStudentBase).select('student_id', 'reg_number') |
---|
| 98 | |
---|
| 99 | post_text = ''' |
---|
[16791] | 100 | This admission will be confirmed upon payment of school fees. |
---|
[16695] | 101 | |
---|
[17379] | 102 | Note: All admitted students are to pay their school fees on or before 8th of May 2023. |
---|
[16791] | 103 | |
---|
[17028] | 104 | Also, hostel accommodation is available on first come first serve basis. |
---|
[16791] | 105 | |
---|
[16697] | 106 | Please visit the College Registry (Student Affairs Division) at: |
---|
[16695] | 107 | |
---|
[16696] | 108 | Edo State College of Nursing Sciences |
---|
[16697] | 109 | Godwin Abbey Way (Formerly Limit Road) off Sapele Road, Benin City |
---|
[16696] | 110 | or call 08104797237 for enquiries. |
---|
[16695] | 111 | |
---|
| 112 | Congratulations! |
---|
| 113 | ''' |
---|
| 114 | |
---|
| 115 | @property |
---|
| 116 | def label(self): |
---|
| 117 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 118 | return translate(_('Admission Letter of'), |
---|
| 119 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 120 | + ' %s' % self.context.display_fullname |
---|
| 121 | |
---|
| 122 | def render(self): |
---|
| 123 | students_utils = getUtility(IStudentsUtils) |
---|
| 124 | letterhead_path = os.path.join( |
---|
| 125 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
| 126 | if not os.path.exists(letterhead_path): |
---|
| 127 | letterhead_path = None |
---|
| 128 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 129 | self.context.student, omit_fields=self.omit_fields, |
---|
| 130 | letterhead_path=letterhead_path, post_text=self.post_text) |
---|
| 131 | |
---|
[16712] | 132 | |
---|
| 133 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
| 134 | """Deliver a PDF slip of the context. |
---|
| 135 | """ |
---|
| 136 | omit_fields = ('password', 'suspended', 'suspended_comment', 'phone', |
---|
| 137 | 'adm_code', 'sex', 'email', 'date_of_birth', 'current_level', |
---|
| 138 | 'flash_notice', 'certificate', 'faculty', 'parents_email') |
---|
| 139 | |
---|
[16715] | 140 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 141 | """ Page to manage the student payments. This manage form page is for |
---|
| 142 | both students and students officers. EDOCONS does not allow students |
---|
| 143 | to remove any payment ticket. |
---|
| 144 | """ |
---|
| 145 | @property |
---|
| 146 | def manage_payments_allowed(self): |
---|
| 147 | return checkPermission('waeup.manageStudent', self.context) |
---|
| 148 | |
---|
[17163] | 149 | class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage): |
---|
| 150 | grok.require('waeup.payStudent') |
---|
[16796] | 151 | |
---|
[16846] | 152 | |
---|
| 153 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
[17345] | 154 | with_ac = False |
---|
| 155 | |
---|
| 156 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 157 | """ Page to display student study levels |
---|
| 158 | """ |
---|
| 159 | @property |
---|
| 160 | def translated_values(self): |
---|
| 161 | return translated_values(self) |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
---|
| 165 | """ Page to display course tickets |
---|
| 166 | """ |
---|
| 167 | form_fields = grok.AutoFields(ICustomCourseTicket).omit('course_category', |
---|
| 168 | 'ticket_session') |
---|
| 169 | |
---|
| 170 | @property |
---|
| 171 | def form_fields(self): |
---|
| 172 | if not self.context.carry_over: |
---|
| 173 | return grok.AutoFields(ICustomCourseTicket).omit('carryover_score') |
---|
| 174 | return grok.AutoFields(ICustomCourseTicket) |
---|
| 175 | |
---|
| 176 | class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): |
---|
| 177 | """ Page to manage course tickets |
---|
| 178 | """ |
---|
| 179 | form_fields = grok.AutoFields(ICustomCourseTicket) |
---|