1 | ## $Id: browser.py 17566 2023-08-30 08:22:36Z 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 | import os |
---|
20 | from zope.i18n import translate |
---|
21 | from zope.component import getUtility |
---|
22 | from zope.security import checkPermission |
---|
23 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
24 | from waeup.kofa.interfaces import ADMITTED, VALIDATED, IKofaUtils |
---|
25 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
26 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
27 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
28 | from waeup.kofa.students.browser import ( |
---|
29 | StartClearancePage, |
---|
30 | ExportPDFAdmissionSlip, StudyLevelDisplayFormPage, |
---|
31 | PaymentsManageFormPage, |
---|
32 | OnlinePaymentApproveView, |
---|
33 | StudentBasePDFFormPage) |
---|
34 | from kofacustom.nigeria.students.browser import ( |
---|
35 | NigeriaOnlinePaymentDisplayFormPage, |
---|
36 | NigeriaOnlinePaymentAddFormPage, |
---|
37 | NigeriaExportPDFPaymentSlip, |
---|
38 | NigeriaStudentClearanceEditFormPage, |
---|
39 | NigeriaExportPDFClearanceSlip, |
---|
40 | NigeriaExportPDFCourseRegistrationSlip, |
---|
41 | NigeriaBedTicketAddPage, |
---|
42 | NigeriaAccommodationManageFormPage, |
---|
43 | NigeriaAccommodationDisplayFormPage, |
---|
44 | ) |
---|
45 | |
---|
46 | from waeup.fceokene.students.interfaces import ( |
---|
47 | ICustomStudentOnlinePayment, ICustomUGStudentClearance, |
---|
48 | ICustomStudentStudyLevel) |
---|
49 | |
---|
50 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
51 | """Deliver a PDF Admission slip. |
---|
52 | """ |
---|
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 | |
---|
65 | @property |
---|
66 | def _post_text(self): |
---|
67 | return """You should note the following as conditions for admission: |
---|
68 | |
---|
69 | 1. At the point of registration, you will be required to present the originals of your |
---|
70 | certificate(s), Jamb Original Result, a Birth Certificate or a Declaration of |
---|
71 | Age Certificate and Evidence of Citizenship Certificate. |
---|
72 | |
---|
73 | 2. Please note that the name by which you are hereby admitted and by which you will |
---|
74 | be registered is the one which will appear on any certificate that the |
---|
75 | Federal College of Education, Okene may issue to you on successful completion of |
---|
76 | your programme except there was a change of name by sworn affidavit or |
---|
77 | marriage certificate in addition to newspaper publication. |
---|
78 | |
---|
79 | 3. You are hereby informed that all fees must be paid at the beginning of the |
---|
80 | academic session. The current school fees can be obtained from the College website. |
---|
81 | |
---|
82 | 4. You will present at the time of registration the Medical Certificate of Fitness |
---|
83 | from the Federal College of Education, Okene Medical Centre. |
---|
84 | |
---|
85 | 5. Please, note that due to shortage of accommodations, students shall be given |
---|
86 | accommodations on first come, first serve basis. |
---|
87 | |
---|
88 | 6. The offer is not transferable to another session. |
---|
89 | |
---|
90 | 7. You will sign a declaration of good conduct except by deferment on your |
---|
91 | arrival at the College. |
---|
92 | |
---|
93 | Accept my congratulations. Yours faithfully |
---|
94 | |
---|
95 | Ajoge E, A |
---|
96 | Deputy Registrar (Admissions) |
---|
97 | For: Registrar |
---|
98 | """ |
---|
99 | |
---|
100 | def render(self): |
---|
101 | students_utils = getUtility(IStudentsUtils) |
---|
102 | letterhead_path = os.path.join( |
---|
103 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
104 | topMargin=1.6 |
---|
105 | if self.context.student.current_mode.startswith('ug'): |
---|
106 | letterhead_path = None |
---|
107 | topMargin=1.5 |
---|
108 | return students_utils.renderPDFAdmissionLetter(self, |
---|
109 | self.context.student, omit_fields=self.omit_fields, |
---|
110 | letterhead_path=letterhead_path, |
---|
111 | topMargin=topMargin, |
---|
112 | post_text=self._post_text) |
---|
113 | |
---|
114 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
115 | """ Page to view an online payment ticket |
---|
116 | """ |
---|
117 | grok.context(ICustomStudentOnlinePayment) |
---|
118 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
119 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
120 | form_fields[ |
---|
121 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
122 | form_fields[ |
---|
123 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
124 | |
---|
125 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
126 | """ Page to add an online payment ticket |
---|
127 | """ |
---|
128 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
129 | 'p_combi') |
---|
130 | |
---|
131 | class OnlinePaymentApproveView(OnlinePaymentApproveView): |
---|
132 | grok.require('waeup.manageStudent') |
---|
133 | |
---|
134 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
135 | """Deliver a PDF slip of the context. |
---|
136 | """ |
---|
137 | grok.context(ICustomStudentOnlinePayment) |
---|
138 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
139 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
140 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
141 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
142 | |
---|
143 | class CustomStartClearancePage(StartClearancePage): |
---|
144 | |
---|
145 | @property |
---|
146 | def with_ac(self): |
---|
147 | mode = getattr(self.context, 'current_mode', None) |
---|
148 | if mode and mode.startswith('ug'): |
---|
149 | return True |
---|
150 | return False |
---|
151 | |
---|
152 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
153 | """Deliver a PDF slip of the context. |
---|
154 | """ |
---|
155 | |
---|
156 | @property |
---|
157 | def form_fields(self): |
---|
158 | if self.context.is_postgrad: |
---|
159 | form_fields = grok.AutoFields( |
---|
160 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
161 | else: |
---|
162 | form_fields = grok.AutoFields( |
---|
163 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
164 | if not getattr(self.context, 'officer_comment'): |
---|
165 | form_fields = form_fields.omit('officer_comment') |
---|
166 | return form_fields |
---|
167 | |
---|
168 | @property |
---|
169 | def label(self): |
---|
170 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
171 | |
---|
172 | line0 = '' |
---|
173 | if self.context.student.current_mode.startswith('ug'): |
---|
174 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
175 | line1 = translate(_('Clearance Slip of'), |
---|
176 | 'waeup.kofa', target_language=portal_language) \ |
---|
177 | + ' %s' % self.context.display_fullname |
---|
178 | return '%s%s' % (line0, line1) |
---|
179 | |
---|
180 | |
---|
181 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
182 | """ View to edit student clearance data by student |
---|
183 | """ |
---|
184 | |
---|
185 | def dataNotComplete(self): |
---|
186 | return False |
---|
187 | |
---|
188 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
189 | """ Page to add an online payment ticket |
---|
190 | """ |
---|
191 | buttonname = _('Create bed ticket') |
---|
192 | notice = '' |
---|
193 | with_ac = False |
---|
194 | with_bedselection = True |
---|
195 | |
---|
196 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
197 | """ Page to display student study levels |
---|
198 | """ |
---|
199 | grok.context(ICustomStudentStudyLevel) |
---|
200 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
201 | form_fields[ |
---|
202 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
203 | |
---|
204 | class CustomExportPDFCourseRegistrationSlip( |
---|
205 | NigeriaExportPDFCourseRegistrationSlip): |
---|
206 | """Deliver a PDF slip of the context. |
---|
207 | """ |
---|
208 | grok.context(ICustomStudentStudyLevel) |
---|
209 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
210 | |
---|
211 | class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip): |
---|
212 | """Deliver a PDF slip of the context. |
---|
213 | """ |
---|
214 | grok.name('examination_clearance_slip_1.pdf') |
---|
215 | form_fields = None |
---|
216 | omit_fields = ( |
---|
217 | 'password', 'suspended', 'phone', 'date_of_birth', |
---|
218 | 'parents_email', 'current_mode', 'entry_session', |
---|
219 | 'adm_code', 'sex', 'suspended_comment', |
---|
220 | 'flash_notice') |
---|
221 | semester = 1 |
---|
222 | tabletitle = ['', '', ''] |
---|
223 | |
---|
224 | @property |
---|
225 | def label(self): |
---|
226 | return '%s First Semester Examination Clearance' % self.context.level_session |
---|
227 | |
---|
228 | @property |
---|
229 | def title(self): |
---|
230 | return '' |
---|
231 | |
---|
232 | def update(self): |
---|
233 | if self.context.student.state != VALIDATED \ |
---|
234 | or self.context.student.current_level != self.context.level: |
---|
235 | self.flash(_('Forbidden'), type="warning") |
---|
236 | self.redirect(self.url(self.context)) |
---|
237 | |
---|
238 | def render(self): |
---|
239 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
240 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
241 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
242 | self.request, self.omit_fields) |
---|
243 | students_utils = getUtility(IStudentsUtils) |
---|
244 | |
---|
245 | tabledata = [] |
---|
246 | tableheader = [] |
---|
247 | for i in range(1,7): |
---|
248 | tabledata.append(sorted( |
---|
249 | [value for value in self.context.values() if i == self.semester == value.semester], |
---|
250 | key=lambda value: value.code)) |
---|
251 | tableheader.append([(Code,'code', 2.5), |
---|
252 | ('Invigilator\'s Name','inv', 8), |
---|
253 | ('Signature and Date','sig', 7), |
---|
254 | ]) |
---|
255 | return students_utils.renderPDF( |
---|
256 | self, 'examination_clearance_slip_%s.pdf' % self.semester, |
---|
257 | self.context.student, studentview, |
---|
258 | tableheader=tableheader, |
---|
259 | tabledata=tabledata, |
---|
260 | omit_fields=self.omit_fields, |
---|
261 | topMargin=1.3 |
---|
262 | ) |
---|
263 | |
---|
264 | class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1): |
---|
265 | """Deliver a PDF slip of the context. |
---|
266 | """ |
---|
267 | grok.name('examination_clearance_slip_2.pdf') |
---|
268 | semester = 2 |
---|
269 | |
---|
270 | @property |
---|
271 | def label(self): |
---|
272 | return '%s Second Semester Examination Clearance' % self.context.level_session |
---|
273 | |
---|
274 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
275 | """ Page to manage the student payments. This manage form page is for |
---|
276 | both students and students officers. FCEOkene does not allow students |
---|
277 | to remove any payment ticket. |
---|
278 | """ |
---|
279 | @property |
---|
280 | def manage_payments_allowed(self): |
---|
281 | return checkPermission('waeup.manageStudent', self.context) |
---|
282 | |
---|
283 | class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): |
---|
284 | """ Page to view bed tickets. |
---|
285 | """ |
---|
286 | with_hostel_selection = True |
---|
287 | |
---|
288 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
289 | """ Page to manage bed tickets. |
---|
290 | This manage form page is for both students and students officers. |
---|
291 | """ |
---|
292 | with_hostel_selection = True |
---|