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

Last change on this file since 15991 was 15989, checked in by Henrik Bettermann, 5 years ago

Provide two ExportPDFExaminationClearanceSlip pages.

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