1 | ## $Id: browser.py 15690 2019-10-15 20:14:52Z 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 |
---|
20 | from zope.component import getUtility |
---|
21 | from zope.security import checkPermission |
---|
22 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
23 | from waeup.kofa.interfaces import ADMITTED, IKofaUtils |
---|
24 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
25 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
26 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
27 | from waeup.kofa.students.browser import ( |
---|
28 | StartClearancePage, BedTicketAddPage, |
---|
29 | ExportPDFAdmissionSlip, StudyLevelDisplayFormPage, |
---|
30 | PaymentsManageFormPage) |
---|
31 | from kofacustom.nigeria.students.browser import ( |
---|
32 | NigeriaOnlinePaymentDisplayFormPage, |
---|
33 | NigeriaOnlinePaymentAddFormPage, |
---|
34 | NigeriaExportPDFPaymentSlip, |
---|
35 | NigeriaStudentClearanceEditFormPage, |
---|
36 | NigeriaExportPDFClearanceSlip, |
---|
37 | NigeriaExportPDFCourseRegistrationSlip |
---|
38 | ) |
---|
39 | |
---|
40 | from waeup.fceokene.students.interfaces import ( |
---|
41 | ICustomStudentOnlinePayment, ICustomUGStudentClearance, |
---|
42 | ICustomStudentStudyLevel) |
---|
43 | |
---|
44 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
45 | """Deliver a PDF Admission slip. |
---|
46 | """ |
---|
47 | |
---|
48 | @property |
---|
49 | def label(self): |
---|
50 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
51 | line0 = '' |
---|
52 | if self.context.student.current_mode.startswith('ug'): |
---|
53 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
54 | line1 = translate(_('Admission Letter of'), |
---|
55 | 'waeup.kofa', target_language=portal_language) \ |
---|
56 | + ' %s' % self.context.display_fullname |
---|
57 | return '%s%s' % (line0, line1) |
---|
58 | |
---|
59 | @property |
---|
60 | def _post_text(self): |
---|
61 | return """You should note the following as conditions for admission: |
---|
62 | |
---|
63 | 1. At the point of registration, you will be required to present the originals |
---|
64 | of your certificate(s), Jamb Original Result, a Birth Certificate or a Declaration |
---|
65 | of Age Certificate and Evidence of Citizenship Certificate. |
---|
66 | |
---|
67 | 2. Please note that the name by which you are hereby admitted and by which you |
---|
68 | will be registered is the one which will appear on any certificate that the |
---|
69 | Federal College of Education, Okene may issue to you on successful completion |
---|
70 | of your programme except there was a change of name by sworn affidavit or |
---|
71 | marriage certificate in addition to newspaper publication. |
---|
72 | |
---|
73 | 3. You are hereby informed that all fees must be paid at the beginning of |
---|
74 | the academic session. The current school fees can be obtained from the |
---|
75 | College website. |
---|
76 | |
---|
77 | 4. You will present at the time of registration the Medical Certificate of |
---|
78 | Fitness from the Federal College of Education, Okene Medical Centre. |
---|
79 | |
---|
80 | 5. Please, note that due to shortage of accommodations, students shall be |
---|
81 | given accommodations on first come, first serve basis. |
---|
82 | |
---|
83 | 6. The offer is not transferable to another session. |
---|
84 | |
---|
85 | 7. You will sign a declaration of good conduct except by deferment on your |
---|
86 | arrival at the College. |
---|
87 | |
---|
88 | Accept my congratulations. |
---|
89 | |
---|
90 | Yours faithfully |
---|
91 | |
---|
92 | M. S. Adoke |
---|
93 | Deputy Registrar (Admissions) |
---|
94 | For: Registrar |
---|
95 | """ |
---|
96 | |
---|
97 | |
---|
98 | def render(self): |
---|
99 | students_utils = getUtility(IStudentsUtils) |
---|
100 | return students_utils.renderPDFAdmissionLetter(self, |
---|
101 | self.context.student, omit_fields=self.omit_fields, |
---|
102 | post_text=self._post_text) |
---|
103 | |
---|
104 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
105 | """ Page to view an online payment ticket |
---|
106 | """ |
---|
107 | grok.context(ICustomStudentOnlinePayment) |
---|
108 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
109 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
110 | form_fields[ |
---|
111 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
112 | form_fields[ |
---|
113 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
114 | |
---|
115 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
116 | """ Page to add an online payment ticket |
---|
117 | """ |
---|
118 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
119 | 'p_combi') |
---|
120 | |
---|
121 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
122 | """Deliver a PDF slip of the context. |
---|
123 | """ |
---|
124 | grok.context(ICustomStudentOnlinePayment) |
---|
125 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
126 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
127 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
128 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
129 | |
---|
130 | note = ''' |
---|
131 | |
---|
132 | |
---|
133 | The total authorized amount includes an Interswitch transaction charge of 150 Nairas. |
---|
134 | ''' |
---|
135 | |
---|
136 | class CustomStartClearancePage(StartClearancePage): |
---|
137 | |
---|
138 | @property |
---|
139 | def with_ac(self): |
---|
140 | mode = getattr(self.context, 'current_mode', None) |
---|
141 | if mode and mode.startswith('ug'): |
---|
142 | return True |
---|
143 | return False |
---|
144 | |
---|
145 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
146 | """Deliver a PDF slip of the context. |
---|
147 | """ |
---|
148 | |
---|
149 | @property |
---|
150 | def form_fields(self): |
---|
151 | if self.context.is_postgrad: |
---|
152 | form_fields = grok.AutoFields( |
---|
153 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
154 | else: |
---|
155 | form_fields = grok.AutoFields( |
---|
156 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
157 | if not getattr(self.context, 'officer_comment'): |
---|
158 | form_fields = form_fields.omit('officer_comment') |
---|
159 | return form_fields |
---|
160 | |
---|
161 | @property |
---|
162 | def label(self): |
---|
163 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
164 | |
---|
165 | line0 = '' |
---|
166 | if self.context.student.current_mode.startswith('ug'): |
---|
167 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
168 | line1 = translate(_('Clearance Slip of'), |
---|
169 | 'waeup.kofa', target_language=portal_language) \ |
---|
170 | + ' %s' % self.context.display_fullname |
---|
171 | return '%s%s' % (line0, line1) |
---|
172 | |
---|
173 | |
---|
174 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
175 | """ View to edit student clearance data by student |
---|
176 | """ |
---|
177 | |
---|
178 | def dataNotComplete(self): |
---|
179 | return False |
---|
180 | |
---|
181 | class CustomBedTicketAddPage(BedTicketAddPage): |
---|
182 | """ Page to add an online payment ticket |
---|
183 | """ |
---|
184 | buttonname = _('Create bed ticket') |
---|
185 | notice = '' |
---|
186 | with_ac = False |
---|
187 | |
---|
188 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
189 | """ Page to display student study levels |
---|
190 | """ |
---|
191 | grok.context(ICustomStudentStudyLevel) |
---|
192 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
193 | form_fields[ |
---|
194 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
195 | |
---|
196 | class CustomExportPDFCourseRegistrationSlip( |
---|
197 | NigeriaExportPDFCourseRegistrationSlip): |
---|
198 | """Deliver a PDF slip of the context. |
---|
199 | """ |
---|
200 | grok.context(ICustomStudentStudyLevel) |
---|
201 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
202 | |
---|
203 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
204 | """ Page to manage the student payments. This manage form page is for |
---|
205 | both students and students officers. FCEOkene does not allow students |
---|
206 | to remove any payment ticket. |
---|
207 | """ |
---|
208 | @property |
---|
209 | def manage_payments_allowed(self): |
---|
210 | return checkPermission('waeup.manageStudent', self.context) |
---|