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
RevLine 
[8911]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
[15887]19import os
[8911]20from zope.i18n import translate
[9945]21from zope.component import getUtility
[15304]22from zope.security import checkPermission
[9156]23from hurry.workflow.interfaces import IWorkflowInfo
[15977]24from waeup.kofa.interfaces import ADMITTED, VALIDATED, IKofaUtils
[9156]25from waeup.kofa.interfaces import MessageFactory as _
[8911]26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15507]27from waeup.kofa.students.interfaces import IStudentsUtils
[9945]28from waeup.kofa.students.browser import (
[15717]29    StartClearancePage,
[15304]30    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage,
[15940]31    PaymentsManageFormPage,
[15977]32    OnlinePaymentApproveView,
33    StudentBasePDFFormPage)
[8911]34from kofacustom.nigeria.students.browser import (
35    NigeriaOnlinePaymentDisplayFormPage,
36    NigeriaOnlinePaymentAddFormPage,
[13060]37    NigeriaExportPDFPaymentSlip,
[9190]38    NigeriaStudentClearanceEditFormPage,
[14591]39    NigeriaExportPDFClearanceSlip,
[15717]40    NigeriaExportPDFCourseRegistrationSlip,
41    NigeriaBedTicketAddPage,
[9190]42    )
[8911]43
[10019]44from waeup.fceokene.students.interfaces import (
[14591]45    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
46    ICustomStudentStudyLevel)
[8911]47
[13060]48class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
[9945]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
[15507]63    @property
64    def _post_text(self):
65        return """You should note the following as conditions for admission:
66
[15887]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.
[15690]70
[15887]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.
[15690]75
[15887]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.
[15690]78
[15887]794. You will present at the time of registration the Medical Certificate of Fitness from the Federal
80   College of Education, Okene Medical Centre.
[15690]81
[15887]825. Please, note that due to shortage of accommodations, students shall be given accommodations
83   on first come, first serve basis.
[15690]84
[15509]856. The offer is not transferable to another session.
[15507]86
[15887]877. You will sign a declaration of good conduct except by deferment on your arrival at the College.
[15690]88
[15507]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)
[15887]100        letterhead_path = os.path.join(
101            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
[15894]102        topMargin=1.6
[15887]103        if self.context.student.current_mode.startswith('ug'):
104            letterhead_path = None
[15890]105            topMargin=1.5
[15507]106        return students_utils.renderPDFAdmissionLetter(self,
107            self.context.student, omit_fields=self.omit_fields,
[15887]108            letterhead_path=letterhead_path,
[15890]109            topMargin=topMargin,
[15507]110            post_text=self._post_text)
111
[8911]112class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
113    """ Page to view an online payment ticket
114    """
115    grok.context(ICustomStudentOnlinePayment)
[9780]116    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]117        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]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(
[15668]127        'p_combi')
[8911]128
[15940]129class OnlinePaymentApproveView(OnlinePaymentApproveView):
130    grok.require('waeup.manageStudent')
131
[13060]132class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
[8911]133    """Deliver a PDF slip of the context.
134    """
135    grok.context(ICustomStudentOnlinePayment)
[9780]136    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]137        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]138    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9156]139    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
140
141class CustomStartClearancePage(StartClearancePage):
142
[9953]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
[9156]149
[13060]150class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
[10019]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
[9181]179class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
180    """ View to edit student clearance data by student
181    """
182
183    def dataNotComplete(self):
[9190]184        return False
185
[15717]186class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
[9190]187    """ Page to add an online payment ticket
188    """
189    buttonname = _('Create bed ticket')
190    notice = ''
[14591]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)
[15304]206    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
207
[15989]208class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip):
[15977]209    """Deliver a PDF slip of the context.
210    """
[15989]211    grok.name('examination_clearance_slip_1.pdf')
[15982]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')
[15989]218    semester = 1
219    tabletitle =  ['', '', '']
[15982]220
[15977]221    @property
222    def label(self):
[15989]223        return '%s First Semester Examination Clearance' % self.context.level_session
[15977]224
[15982]225    @property
226    def title(self):
227        return ''
228
[15977]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(
[15989]246                [value for value in self.context.values() if i == self.semester == value.semester],
247                key=lambda value: value.code))
[15977]248            tableheader.append([(Code,'code', 2.5),
[15989]249                             ('Invigilator\'s Name','inv', 8),
250                             ('Signature','sig', 7),
[15977]251                             ])
252        return students_utils.renderPDF(
[15989]253            self, 'examination_clearance_slip_%s.pdf' % self.semester,
[15977]254            self.context.student, studentview,
255            tableheader=tableheader,
256            tabledata=tabledata,
[15983]257            omit_fields=self.omit_fields,
[15989]258            topMargin=1.3
[15977]259            )
260
[15989]261class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1):
262    """Deliver a PDF slip of the context.
263    """
264    grok.name('examination_clearance_slip_2.pdf')
265    semester = 2
[15977]266
[15989]267    @property
268    def label(self):
269        return '%s Second Semester Examination Clearance' % self.context.level_session
270
[15304]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.