source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/browser.py @ 18122

Last change on this file since 18122 was 18067, checked in by Henrik Bettermann, 3 months ago

Add JAMB registration number and NIN.

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