1 | ## $Id: browser.py 17577 2023-09-13 05:25:21Z 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. Students shall be given accommodations on first come, first serve basis. |
---|
86 | |
---|
87 | 6. The offer is not transferable to another session. |
---|
88 | |
---|
89 | 7. You will sign a declaration of good conduct except by deferment on your |
---|
90 | arrival at the College. |
---|
91 | |
---|
92 | Accept my congratulations. Yours faithfully |
---|
93 | |
---|
94 | Ajoge E, A |
---|
95 | Deputy Registrar (Admissions) |
---|
96 | For: Registrar |
---|
97 | """ |
---|
98 | |
---|
99 | def render(self): |
---|
100 | students_utils = getUtility(IStudentsUtils) |
---|
101 | letterhead_path = os.path.join( |
---|
102 | os.path.dirname(__file__), 'static', 'letterhead_admission.jpg') |
---|
103 | topMargin=1.6 |
---|
104 | if self.context.student.current_mode.startswith('ug'): |
---|
105 | letterhead_path = None |
---|
106 | topMargin=1.5 |
---|
107 | return students_utils.renderPDFAdmissionLetter(self, |
---|
108 | self.context.student, omit_fields=self.omit_fields, |
---|
109 | letterhead_path=letterhead_path, |
---|
110 | topMargin=topMargin, |
---|
111 | post_text=self._post_text) |
---|
112 | |
---|
113 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
114 | """ Page to view an online payment ticket |
---|
115 | """ |
---|
116 | grok.context(ICustomStudentOnlinePayment) |
---|
117 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
118 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
119 | form_fields[ |
---|
120 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
121 | form_fields[ |
---|
122 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
123 | |
---|
124 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
125 | """ Page to add an online payment ticket |
---|
126 | """ |
---|
127 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
128 | 'p_combi') |
---|
129 | |
---|
130 | class OnlinePaymentApproveView(OnlinePaymentApproveView): |
---|
131 | grok.require('waeup.manageStudent') |
---|
132 | |
---|
133 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
134 | """Deliver a PDF slip of the context. |
---|
135 | """ |
---|
136 | grok.context(ICustomStudentOnlinePayment) |
---|
137 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
138 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi') |
---|
139 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
140 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
141 | |
---|
142 | class CustomStartClearancePage(StartClearancePage): |
---|
143 | |
---|
144 | @property |
---|
145 | def with_ac(self): |
---|
146 | mode = getattr(self.context, 'current_mode', None) |
---|
147 | if mode and mode.startswith('ug'): |
---|
148 | return True |
---|
149 | return False |
---|
150 | |
---|
151 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
152 | """Deliver a PDF slip of the context. |
---|
153 | """ |
---|
154 | |
---|
155 | @property |
---|
156 | def form_fields(self): |
---|
157 | if self.context.is_postgrad: |
---|
158 | form_fields = grok.AutoFields( |
---|
159 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
160 | else: |
---|
161 | form_fields = grok.AutoFields( |
---|
162 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
163 | if not getattr(self.context, 'officer_comment'): |
---|
164 | form_fields = form_fields.omit('officer_comment') |
---|
165 | return form_fields |
---|
166 | |
---|
167 | @property |
---|
168 | def label(self): |
---|
169 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
170 | |
---|
171 | line0 = '' |
---|
172 | if self.context.student.current_mode.startswith('ug'): |
---|
173 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
174 | line1 = translate(_('Clearance Slip of'), |
---|
175 | 'waeup.kofa', target_language=portal_language) \ |
---|
176 | + ' %s' % self.context.display_fullname |
---|
177 | return '%s%s' % (line0, line1) |
---|
178 | |
---|
179 | |
---|
180 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
181 | """ View to edit student clearance data by student |
---|
182 | """ |
---|
183 | |
---|
184 | def dataNotComplete(self): |
---|
185 | return False |
---|
186 | |
---|
187 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
188 | """ Page to add an online payment ticket |
---|
189 | """ |
---|
190 | buttonname = _('Create bed ticket') |
---|
191 | notice = '' |
---|
192 | with_ac = False |
---|
193 | with_bedselection = True |
---|
194 | |
---|
195 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
196 | """ Page to display student study levels |
---|
197 | """ |
---|
198 | grok.context(ICustomStudentStudyLevel) |
---|
199 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
200 | form_fields[ |
---|
201 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
202 | |
---|
203 | class CustomExportPDFCourseRegistrationSlip( |
---|
204 | NigeriaExportPDFCourseRegistrationSlip): |
---|
205 | """Deliver a PDF slip of the context. |
---|
206 | """ |
---|
207 | grok.context(ICustomStudentStudyLevel) |
---|
208 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level') |
---|
209 | |
---|
210 | class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip): |
---|
211 | """Deliver a PDF slip of the context. |
---|
212 | """ |
---|
213 | grok.name('examination_clearance_slip_1.pdf') |
---|
214 | form_fields = None |
---|
215 | omit_fields = ( |
---|
216 | 'password', 'suspended', 'phone', 'date_of_birth', |
---|
217 | 'parents_email', 'current_mode', 'entry_session', |
---|
218 | 'adm_code', 'sex', 'suspended_comment', |
---|
219 | 'flash_notice') |
---|
220 | semester = 1 |
---|
221 | tabletitle = ['', '', ''] |
---|
222 | |
---|
223 | @property |
---|
224 | def label(self): |
---|
225 | return '%s First Semester Examination Clearance' % self.context.level_session |
---|
226 | |
---|
227 | @property |
---|
228 | def title(self): |
---|
229 | return '' |
---|
230 | |
---|
231 | def update(self): |
---|
232 | if self.context.student.state != VALIDATED \ |
---|
233 | or self.context.student.current_level != self.context.level: |
---|
234 | self.flash(_('Forbidden'), type="warning") |
---|
235 | self.redirect(self.url(self.context)) |
---|
236 | |
---|
237 | def render(self): |
---|
238 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
239 | Code = translate('Code', 'waeup.kofa', target_language=portal_language) |
---|
240 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
241 | self.request, self.omit_fields) |
---|
242 | students_utils = getUtility(IStudentsUtils) |
---|
243 | |
---|
244 | tabledata = [] |
---|
245 | tableheader = [] |
---|
246 | for i in range(1,7): |
---|
247 | tabledata.append(sorted( |
---|
248 | [value for value in self.context.values() if i == self.semester == value.semester], |
---|
249 | key=lambda value: value.code)) |
---|
250 | tableheader.append([(Code,'code', 2.5), |
---|
251 | ('Invigilator\'s Name','inv', 8), |
---|
252 | ('Signature and Date','sig', 7), |
---|
253 | ]) |
---|
254 | return students_utils.renderPDF( |
---|
255 | self, 'examination_clearance_slip_%s.pdf' % self.semester, |
---|
256 | self.context.student, studentview, |
---|
257 | tableheader=tableheader, |
---|
258 | tabledata=tabledata, |
---|
259 | omit_fields=self.omit_fields, |
---|
260 | topMargin=1.3 |
---|
261 | ) |
---|
262 | |
---|
263 | class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1): |
---|
264 | """Deliver a PDF slip of the context. |
---|
265 | """ |
---|
266 | grok.name('examination_clearance_slip_2.pdf') |
---|
267 | semester = 2 |
---|
268 | |
---|
269 | @property |
---|
270 | def label(self): |
---|
271 | return '%s Second Semester Examination Clearance' % self.context.level_session |
---|
272 | |
---|
273 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
274 | """ Page to manage the student payments. This manage form page is for |
---|
275 | both students and students officers. FCEOkene does not allow students |
---|
276 | to remove any payment ticket. |
---|
277 | """ |
---|
278 | @property |
---|
279 | def manage_payments_allowed(self): |
---|
280 | return checkPermission('waeup.manageStudent', self.context) |
---|
281 | |
---|
282 | class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage): |
---|
283 | """ Page to view bed tickets. |
---|
284 | """ |
---|
285 | with_hostel_selection = True |
---|
286 | |
---|
287 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
288 | """ Page to manage bed tickets. |
---|
289 | This manage form page is for both students and students officers. |
---|
290 | """ |
---|
291 | with_hostel_selection = True |
---|