## $Id: browser.py 17345 2023-03-10 09:13:25Z henrik $ ## ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import grok import os from zope.i18n import translate from zope.schema.interfaces import ConstraintNotSatisfied from zope.component import getUtility from zope.security import checkPermission from hurry.workflow.interfaces import IWorkflowInfo from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget from waeup.kofa.browser.layout import KofaEditFormPage from waeup.kofa.browser.layout import action, jsaction from waeup.kofa.students.browser import ( StudyLevelEditFormPage, StudyLevelDisplayFormPage, StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, CourseTicketDisplayFormPage, CourseTicketManageFormPage, StudyLevelDisplayFormPage, StudentTriggerTransitionFormPage, ExportPDFAdmissionSlip, StartClearancePage, PaymentsManageFormPage, BalancePaymentAddFormPage, msave, emit_lock_message) from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS from kofacustom.nigeria.students.browser import ( NigeriaOnlinePaymentDisplayFormPage, NigeriaStudentBaseManageFormPage, NigeriaStudentClearanceEditFormPage, NigeriaOnlinePaymentAddFormPage, NigeriaExportPDFPaymentSlip, NigeriaExportPDFClearanceSlip, NigeriaExportPDFPaymentSlip, NigeriaBedTicketAddPage, ) from kofacustom.edocons.students.interfaces import ( ICustomStudentOnlinePayment, ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomCourseTicket) from kofacustom.edocons.interfaces import MessageFactory as _ def translated_values(view): """Translate course ticket attribute values to be displayed on studylevel pages. """ lang = view.request.cookies.get('kofa.language') for value in view.context.values(): # We have to unghostify (according to Tres Seaver) the __dict__ # by activating the object, otherwise value_dict will be empty # when calling the first time. value._p_activate() value_dict = dict([i for i in value.__dict__.items()]) value_dict['url'] = view.url(value) value_dict['removable_by_student'] = value.removable_by_student value_dict['mandatory'] = translate(str(value.mandatory), 'zope', target_language=lang) value_dict['carry_over'] = translate(str(value.carry_over), 'zope', target_language=lang) value_dict['outstanding'] = translate(str(value.outstanding), 'zope', target_language=lang) value_dict['automatic'] = translate(str(value.automatic), 'zope', target_language=lang) value_dict['grade'] = value.grade value_dict['weight'] = value.weight value_dict['course_category'] = value.course_category value_dict['total_score'] = value.total_score semester_dict = getUtility(IKofaUtils).SEMESTER_DICT value_dict['semester'] = semester_dict[ value.semester].replace('mester', 'm.') # ECNS specific value_dict['carryover_score'] = value.carryover_score yield value_dict class CustomStartClearancePage(StartClearancePage): with_ac = False class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): """Deliver a PDF Admission slip. """ omit_fields = ('date_of_birth', 'current_level', 'current_mode', 'certificate', 'faculty') #form_fields = grok.AutoFields(IStudentBase).select('student_id', 'reg_number') post_text = ''' This admission will be confirmed upon payment of school fees. Note: All admitted students are to pay their school fees on or before 28th of February 2023. Also, hostel accommodation is available on first come first serve basis. Please visit the College Registry (Student Affairs Division) at: Edo State College of Nursing Sciences Godwin Abbey Way (Formerly Limit Road) off Sapele Road, Benin City or call 08104797237 for enquiries. Congratulations! ''' @property def label(self): portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE return translate(_('Admission Letter of'), 'waeup.kofa', target_language=portal_language) \ + ' %s' % self.context.display_fullname def render(self): students_utils = getUtility(IStudentsUtils) letterhead_path = os.path.join( os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') if not os.path.exists(letterhead_path): letterhead_path = None return students_utils.renderPDFAdmissionLetter(self, self.context.student, omit_fields=self.omit_fields, letterhead_path=letterhead_path, post_text=self.post_text) class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): """Deliver a PDF slip of the context. """ omit_fields = ('password', 'suspended', 'suspended_comment', 'phone', 'adm_code', 'sex', 'email', 'date_of_birth', 'current_level', 'flash_notice', 'certificate', 'faculty', 'parents_email') class CustomPaymentsManageFormPage(PaymentsManageFormPage): """ Page to manage the student payments. This manage form page is for both students and students officers. EDOCONS does not allow students to remove any payment ticket. """ @property def manage_payments_allowed(self): return checkPermission('waeup.manageStudent', self.context) class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage): grok.require('waeup.payStudent') class CustomBedTicketAddPage(NigeriaBedTicketAddPage): with_ac = False class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): """ Page to display student study levels """ @property def translated_values(self): return translated_values(self) class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): """ Page to display course tickets """ form_fields = grok.AutoFields(ICustomCourseTicket).omit('course_category', 'ticket_session') @property def form_fields(self): if not self.context.carry_over: return grok.AutoFields(ICustomCourseTicket).omit('carryover_score') return grok.AutoFields(ICustomCourseTicket) class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): """ Page to manage course tickets """ form_fields = grok.AutoFields(ICustomCourseTicket)