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