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