[16717] | 1 | ## $Id: browser.py 17737 2024-04-16 06:29:43Z 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 |
---|
| 19 | from zope.i18n import translate |
---|
| 20 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
| 21 | from zope.component import getUtility |
---|
[16718] | 22 | from zope.security import checkPermission |
---|
[17737] | 23 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[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 ( |
---|
[17737] | 30 | StudentPersonalDisplayFormPage, |
---|
| 31 | StudentPersonalManageFormPage, |
---|
| 32 | StudentPersonalEditFormPage, |
---|
| 33 | StudentClearanceDisplayFormPage, |
---|
| 34 | StudentClearanceManageFormPage, |
---|
| 35 | StudentClearanceEditFormPage, |
---|
| 36 | ExportPDFClearanceSlip, |
---|
| 37 | StudyLevelEditFormPage, |
---|
| 38 | StudyLevelDisplayFormPage, |
---|
| 39 | StudentBasePDFFormPage, |
---|
| 40 | ExportPDFCourseRegistrationSlip, |
---|
| 41 | CourseTicketDisplayFormPage, |
---|
| 42 | StudentTriggerTransitionFormPage, |
---|
| 43 | PaymentsManageFormPage, |
---|
| 44 | msave, emit_lock_message) |
---|
[15614] | 45 | from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket |
---|
| 46 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
| 47 | from kofacustom.nigeria.students.browser import ( |
---|
| 48 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 49 | NigeriaStudentBaseManageFormPage, |
---|
| 50 | NigeriaStudentClearanceEditFormPage, |
---|
| 51 | NigeriaOnlinePaymentAddFormPage, |
---|
| 52 | NigeriaExportPDFPaymentSlip, |
---|
| 53 | ) |
---|
| 54 | |
---|
[17689] | 55 | from kofacustom.udss.students.interfaces import ( |
---|
[17737] | 56 | ICustomStudentOnlinePayment, |
---|
| 57 | ICustomStudentStudyCourse, |
---|
| 58 | ICustomStudentStudyLevel, |
---|
| 59 | ICustomStudentPersonal, |
---|
| 60 | ICustomStudentClearance) |
---|
[17689] | 61 | from kofacustom.udss.interfaces import MessageFactory as _ |
---|
[15614] | 62 | |
---|
[16718] | 63 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 64 | """ Page to manage the student payments. This manage form page is for |
---|
| 65 | both students and students officers. SKELETON does not allow students |
---|
| 66 | to remove any payment ticket. |
---|
| 67 | """ |
---|
| 68 | @property |
---|
| 69 | def manage_payments_allowed(self): |
---|
[17737] | 70 | return checkPermission('waeup.manageStudent', self.context) |
---|
| 71 | |
---|
| 72 | class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
| 73 | """ Page to display student personal data |
---|
| 74 | """ |
---|
| 75 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 76 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 77 | form_fields['mother_res_address'].custom_widget = BytesDisplayWidget |
---|
| 78 | form_fields['father_res_address'].custom_widget = BytesDisplayWidget |
---|
| 79 | form_fields['sponsor_res_address'].custom_widget = BytesDisplayWidget |
---|
| 80 | form_fields[ |
---|
| 81 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 82 | |
---|
| 83 | class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage): |
---|
| 84 | """ Page to edit personal data |
---|
| 85 | """ |
---|
| 86 | form_fields = grok.AutoFields(ICustomStudentPersonal).omit('personal_updated') |
---|
| 87 | |
---|
| 88 | class CustomStudentPersonalManageFormPage(StudentPersonalManageFormPage): |
---|
| 89 | """ Page to edit personal data |
---|
| 90 | """ |
---|
| 91 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 92 | form_fields['personal_updated'].for_display = True |
---|
| 93 | form_fields[ |
---|
| 94 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 95 | |
---|
| 96 | class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
| 97 | """ Page to display student clearance data |
---|
| 98 | """ |
---|
| 99 | |
---|
| 100 | @property |
---|
| 101 | def form_fields(self): |
---|
| 102 | form_fields = grok.AutoFields( |
---|
| 103 | ICustomStudentClearance).omit('clearance_locked') |
---|
| 104 | if not getattr(self.context, 'officer_comment'): |
---|
| 105 | form_fields = form_fields.omit('officer_comment') |
---|
| 106 | else: |
---|
| 107 | form_fields['officer_comment'].custom_widget = BytesDisplayWidget |
---|
| 108 | return form_fields |
---|
| 109 | |
---|
| 110 | class CustomExportPDFClearanceSlip(ExportPDFClearanceSlip): |
---|
| 111 | """Deliver a PDF slip of the context. |
---|
| 112 | """ |
---|
| 113 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
| 114 | 'phone', 'adm_code', 'email', 'date_of_birth', 'current_level', |
---|
| 115 | 'flash_notice') |
---|
| 116 | |
---|
| 117 | @property |
---|
| 118 | def form_fields(self): |
---|
| 119 | form_fields = grok.AutoFields( |
---|
| 120 | ICustomStudentClearance).omit('clearance_locked') |
---|
| 121 | if not getattr(self.context, 'officer_comment'): |
---|
| 122 | form_fields = form_fields.omit('officer_comment') |
---|
| 123 | return form_fields |
---|
| 124 | |
---|
| 125 | class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
| 126 | """ Page to edit student clearance data |
---|
| 127 | """ |
---|
| 128 | |
---|
| 129 | @property |
---|
| 130 | def form_fields(self): |
---|
| 131 | form_fields = grok.AutoFields( |
---|
| 132 | ICustomStudentClearance).omit('clr_code') |
---|
| 133 | return form_fields |
---|
| 134 | |
---|
| 135 | class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
| 136 | """ View to edit student clearance data by student |
---|
| 137 | """ |
---|
| 138 | |
---|
| 139 | @property |
---|
| 140 | def form_fields(self): |
---|
| 141 | form_fields = grok.AutoFields(ICustomStudentClearance).omit( |
---|
| 142 | 'clearance_locked', 'clr_code', 'officer_comment', |
---|
| 143 | 'physical_clearance_date') |
---|
| 144 | return form_fields |
---|