[8911] | 1 | ## $Id: browser.py 15304 2019-01-24 14:34:09Z 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 | from zope.i18n import translate |
---|
[9945] | 20 | from zope.component import getUtility |
---|
[15304] | 21 | from zope.security import checkPermission |
---|
[9156] | 22 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[9945] | 23 | from waeup.kofa.interfaces import ADMITTED, IKofaUtils |
---|
[9156] | 24 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[8911] | 25 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[9945] | 26 | from waeup.kofa.students.browser import ( |
---|
[14591] | 27 | StartClearancePage, BedTicketAddPage, |
---|
[15304] | 28 | ExportPDFAdmissionSlip, StudyLevelDisplayFormPage, |
---|
| 29 | PaymentsManageFormPage) |
---|
[8911] | 30 | from kofacustom.nigeria.students.browser import ( |
---|
| 31 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 32 | NigeriaOnlinePaymentAddFormPage, |
---|
[13060] | 33 | NigeriaExportPDFPaymentSlip, |
---|
[9190] | 34 | NigeriaStudentClearanceEditFormPage, |
---|
[14591] | 35 | NigeriaExportPDFClearanceSlip, |
---|
| 36 | NigeriaExportPDFCourseRegistrationSlip |
---|
[9190] | 37 | ) |
---|
[8911] | 38 | |
---|
[10019] | 39 | from waeup.fceokene.students.interfaces import ( |
---|
[14591] | 40 | ICustomStudentOnlinePayment, ICustomUGStudentClearance, |
---|
| 41 | ICustomStudentStudyLevel) |
---|
[8911] | 42 | |
---|
[13060] | 43 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
[9945] | 44 | """Deliver a PDF Admission slip. |
---|
| 45 | """ |
---|
| 46 | |
---|
| 47 | @property |
---|
| 48 | def label(self): |
---|
| 49 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 50 | return translate(_('Admission Letter of'), |
---|
| 51 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 52 | + ' %s' % self.context.display_fullname |
---|
| 53 | |
---|
| 54 | @property |
---|
| 55 | def label(self): |
---|
| 56 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 57 | line0 = '' |
---|
| 58 | if self.context.student.current_mode.startswith('ug'): |
---|
| 59 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
| 60 | line1 = translate(_('Admission Letter of'), |
---|
| 61 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 62 | + ' %s' % self.context.display_fullname |
---|
| 63 | return '%s%s' % (line0, line1) |
---|
| 64 | |
---|
[8911] | 65 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 66 | """ Page to view an online payment ticket |
---|
| 67 | """ |
---|
| 68 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 69 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9986] | 70 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 71 | form_fields[ |
---|
| 72 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 73 | form_fields[ |
---|
| 74 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 75 | |
---|
| 76 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 77 | """ Page to add an online payment ticket |
---|
| 78 | """ |
---|
| 79 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
| 80 | 'p_category') |
---|
| 81 | |
---|
[13060] | 82 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 83 | """Deliver a PDF slip of the context. |
---|
| 84 | """ |
---|
| 85 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 86 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9986] | 87 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 88 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9156] | 89 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 90 | |
---|
[10529] | 91 | note = ''' |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | The total authorized amount includes an Interswitch transaction charge of 150 Nairas. |
---|
| 95 | ''' |
---|
| 96 | |
---|
[9156] | 97 | class CustomStartClearancePage(StartClearancePage): |
---|
| 98 | |
---|
[9953] | 99 | @property |
---|
| 100 | def with_ac(self): |
---|
| 101 | mode = getattr(self.context, 'current_mode', None) |
---|
| 102 | if mode and mode.startswith('ug'): |
---|
| 103 | return True |
---|
| 104 | return False |
---|
[9156] | 105 | |
---|
[13060] | 106 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[10019] | 107 | """Deliver a PDF slip of the context. |
---|
| 108 | """ |
---|
| 109 | |
---|
| 110 | @property |
---|
| 111 | def form_fields(self): |
---|
| 112 | if self.context.is_postgrad: |
---|
| 113 | form_fields = grok.AutoFields( |
---|
| 114 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
| 115 | else: |
---|
| 116 | form_fields = grok.AutoFields( |
---|
| 117 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
| 118 | if not getattr(self.context, 'officer_comment'): |
---|
| 119 | form_fields = form_fields.omit('officer_comment') |
---|
| 120 | return form_fields |
---|
| 121 | |
---|
| 122 | @property |
---|
| 123 | def label(self): |
---|
| 124 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 125 | |
---|
| 126 | line0 = '' |
---|
| 127 | if self.context.student.current_mode.startswith('ug'): |
---|
| 128 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
| 129 | line1 = translate(_('Clearance Slip of'), |
---|
| 130 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 131 | + ' %s' % self.context.display_fullname |
---|
| 132 | return '%s%s' % (line0, line1) |
---|
| 133 | |
---|
| 134 | |
---|
[9181] | 135 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 136 | """ View to edit student clearance data by student |
---|
| 137 | """ |
---|
| 138 | |
---|
| 139 | def dataNotComplete(self): |
---|
[9190] | 140 | return False |
---|
| 141 | |
---|
[9406] | 142 | class CustomBedTicketAddPage(BedTicketAddPage): |
---|
[9190] | 143 | """ Page to add an online payment ticket |
---|
| 144 | """ |
---|
| 145 | buttonname = _('Create bed ticket') |
---|
| 146 | notice = '' |
---|
[14591] | 147 | with_ac = False |
---|
| 148 | |
---|
| 149 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 150 | """ Page to display student study levels |
---|
| 151 | """ |
---|
| 152 | grok.context(ICustomStudentStudyLevel) |
---|
| 153 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 154 | form_fields[ |
---|
| 155 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 156 | |
---|
| 157 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 158 | NigeriaExportPDFCourseRegistrationSlip): |
---|
| 159 | """Deliver a PDF slip of the context. |
---|
| 160 | """ |
---|
| 161 | grok.context(ICustomStudentStudyLevel) |
---|
[15304] | 162 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
| 163 | |
---|
| 164 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 165 | """ Page to manage the student payments. This manage form page is for |
---|
| 166 | both students and students officers. FCEOkene does not allow students |
---|
| 167 | to remove any payment ticket. |
---|
| 168 | """ |
---|
| 169 | @property |
---|
| 170 | def manage_payments_allowed(self): |
---|
| 171 | return checkPermission('waeup.manageStudent', self.context) |
---|