## $Id: browser.py 17737 2024-04-16 06:29:43Z 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 from zope.i18n import translate from zope.schema.interfaces import ConstraintNotSatisfied from zope.component import getUtility from zope.security import checkPermission from zope.formlib.textwidgets import BytesDisplayWidget 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 ( StudentPersonalDisplayFormPage, StudentPersonalManageFormPage, StudentPersonalEditFormPage, StudentClearanceDisplayFormPage, StudentClearanceManageFormPage, StudentClearanceEditFormPage, ExportPDFClearanceSlip, StudyLevelEditFormPage, StudyLevelDisplayFormPage, StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, PaymentsManageFormPage, 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, ) from kofacustom.udss.students.interfaces import ( ICustomStudentOnlinePayment, ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudentPersonal, ICustomStudentClearance) from kofacustom.udss.interfaces import MessageFactory as _ class CustomPaymentsManageFormPage(PaymentsManageFormPage): """ Page to manage the student payments. This manage form page is for both students and students officers. SKELETON does not allow students to remove any payment ticket. """ @property def manage_payments_allowed(self): return checkPermission('waeup.manageStudent', self.context) class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): """ Page to display student personal data """ form_fields = grok.AutoFields(ICustomStudentPersonal) form_fields['perm_address'].custom_widget = BytesDisplayWidget form_fields['mother_res_address'].custom_widget = BytesDisplayWidget form_fields['father_res_address'].custom_widget = BytesDisplayWidget form_fields['sponsor_res_address'].custom_widget = BytesDisplayWidget form_fields[ 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage): """ Page to edit personal data """ form_fields = grok.AutoFields(ICustomStudentPersonal).omit('personal_updated') class CustomStudentPersonalManageFormPage(StudentPersonalManageFormPage): """ Page to edit personal data """ form_fields = grok.AutoFields(ICustomStudentPersonal) form_fields['personal_updated'].for_display = True form_fields[ 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): """ Page to display student clearance data """ @property def form_fields(self): form_fields = grok.AutoFields( ICustomStudentClearance).omit('clearance_locked') if not getattr(self.context, 'officer_comment'): form_fields = form_fields.omit('officer_comment') else: form_fields['officer_comment'].custom_widget = BytesDisplayWidget return form_fields class CustomExportPDFClearanceSlip(ExportPDFClearanceSlip): """Deliver a PDF slip of the context. """ omit_fields = ('password', 'suspended', 'suspended_comment', 'phone', 'adm_code', 'email', 'date_of_birth', 'current_level', 'flash_notice') @property def form_fields(self): form_fields = grok.AutoFields( ICustomStudentClearance).omit('clearance_locked') if not getattr(self.context, 'officer_comment'): form_fields = form_fields.omit('officer_comment') return form_fields class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage): """ Page to edit student clearance data """ @property def form_fields(self): form_fields = grok.AutoFields( ICustomStudentClearance).omit('clr_code') return form_fields class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage): """ View to edit student clearance data by student """ @property def form_fields(self): form_fields = grok.AutoFields(ICustomStudentClearance).omit( 'clearance_locked', 'clr_code', 'officer_comment', 'physical_clearance_date') return form_fields