source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py @ 16233

Last change on this file since 16233 was 16233, checked in by Henrik Bettermann, 4 years ago

Implement PG schoolfee payments.

Show provider_amt in payment ticket pages.

  • Property svn:keywords set to Id
File size: 13.6 KB
Line 
1## $Id: browser.py 16233 2020-09-10 09:33:13Z 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.schema.interfaces import ConstraintNotSatisfied
22from zope.component import getUtility
23from hurry.workflow.interfaces import IWorkflowInfo
24from waeup.kofa.interfaces import (REQUESTED, IExtFileStore, IKofaUtils,
25    academic_sessions_vocab)
26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
27from waeup.kofa.browser.layout import (
28    action, jsaction, UtilityView, KofaEditFormPage)
29from waeup.kofa.students.browser import (
30    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
31    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
32    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
33    StartClearancePage, BalancePaymentAddFormPage,
34    ExportPDFAdmissionSlip,
35    msave, emit_lock_message)
36from waeup.kofa.students.interfaces import (
37    IStudentsUtils, ICourseTicket, IStudent)
38from waeup.kofa.students.vocabularies import StudyLevelSource
39from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
40from kofacustom.nigeria.students.browser import (
41    NigeriaOnlinePaymentDisplayFormPage,
42    NigeriaStudentBaseDisplayFormPage,
43    NigeriaStudentBaseManageFormPage,
44    NigeriaStudentClearanceEditFormPage,
45    NigeriaOnlinePaymentAddFormPage,
46    NigeriaExportPDFPaymentSlip,
47    NigeriaExportPDFClearanceSlip,
48    NigeriaExportPDFCourseRegistrationSlip,
49    NigeriaStudentBaseEditFormPage,
50    NigeriaBedTicketAddPage,
51    NigeriaAccommodationManageFormPage,
52    NigeriaAccommodationDisplayFormPage,
53    )
54
55from kofacustom.iuokada.students.interfaces import (
56    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
57    ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent)
58from kofacustom.iuokada.interfaces import MessageFactory as _
59
60class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage):
61    """ Page to display student base data
62    """
63    form_fields = grok.AutoFields(ICustomStudentBase).omit(
64        'password', 'suspended', 'suspended_comment', 'flash_notice')
65
66class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage):
67    """ View to manage student base data
68    """
69    form_fields = grok.AutoFields(ICustomStudentBase).omit(
70        'student_id', 'adm_code', 'suspended',
71        'financially_cleared_by', 'financial_clearance_date')
72
73class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
74    """ View to edit student base data
75    """
76    form_fields = grok.AutoFields(ICustomStudentBase).select(
77        'email', 'email2', 'parents_email', 'phone',)
78
79class CustomExportPDFCourseRegistrationSlip(
80    NigeriaExportPDFCourseRegistrationSlip):
81    """Deliver a PDF slip of the context.
82    """
83
84    def _signatures(self):
85        return (
86                ['Student Signature'],
87                ['HoD / Course Adviser Signature'],
88                ['College Officer Signature'],
89                ['Dean Signature']
90                )
91
92    #def _sigsInFooter(self):
93    #    return (_('Student'),
94    #            _('HoD / Course Adviser'),
95    #            _('College Officer'),
96    #            _('Dean'),
97    #            )
98    #    return ()
99
100class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
101    """ Page to view bed tickets.
102    """
103    with_hostel_selection = True
104
105class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
106    """ Page to manage bed tickets.
107    This manage form page is for both students and students officers.
108    """
109    with_hostel_selection = True
110
111class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
112    """ Page to add a bed ticket
113    """
114    with_ac = False
115    with_bedselection = True
116
117class StudentGetMatricNumberPage(UtilityView, grok.View):
118    """ Construct and set the matriculation number.
119    """
120    grok.context(IStudent)
121    grok.name('get_matric_number')
122    grok.require('waeup.manageStudent')
123
124    def update(self):
125        students_utils = getUtility(IStudentsUtils)
126        msg, mnumber = students_utils.setMatricNumber(self.context)
127        if msg:
128            self.flash(msg, type="danger")
129        else:
130            self.flash(_('Matriculation number %s assigned.' % mnumber))
131            self.context.writeLogMessage(self, '%s assigned' % mnumber)
132        self.redirect(self.url(self.context))
133        return
134
135    def render(self):
136        return
137
138class SwitchLibraryAccessView(UtilityView, grok.View):
139    """ Switch the library attribute
140    """
141    grok.context(ICustomStudent)
142    grok.name('switch_library_access')
143    grok.require('waeup.switchLibraryAccess')
144
145    def update(self):
146        if self.context.library:
147            self.context.library = False
148            self.context.writeLogMessage(self, 'library access disabled')
149            self.flash(_('Library access disabled'))
150        else:
151            self.context.library = True
152            self.context.writeLogMessage(self, 'library access enabled')
153            self.flash(_('Library access enabled'))
154        self.redirect(self.url(self.context))
155        return
156
157    def render(self):
158        return
159
160class ExportLibIdCard(UtilityView, grok.View):
161    """Deliver an id card for the library.
162    """
163    grok.context(ICustomStudent)
164    grok.name('lib_idcard.pdf')
165    grok.require('waeup.viewStudent')
166    prefix = 'form'
167
168    label = u"Library Clearance"
169
170    omit_fields = (
171        'suspended', 'email', 'phone',
172        'adm_code', 'suspended_comment',
173        'date_of_birth',
174        'current_mode', 'certificate',
175        'entry_session',
176        'flash_notice')
177
178    form_fields = []
179
180    def _sigsInFooter(self):
181        isStudent = getattr(
182            self.request.principal, 'user_type', None) == 'student'
183        if isStudent:
184            return ''
185        return (_("Date, Reader's Signature"),
186                _("Date, Circulation Librarian's Signature"),
187                )
188
189    def update(self):
190        if not self.context.library:
191            self.flash(_('Forbidden!'), type="danger")
192            self.redirect(self.url(self.context))
193        return
194
195    @property
196    def note(self):
197        return """
198<br /><br /><br /><br /><font size='12'>
199This is to certify that the bearer whose photograph and other details appear
200 overleaf is a registered user of the <b>University Library</b>.
201 The card is not transferable. A replacement fee is charged for a loss,
202 mutilation or otherwise. If found, please, return to the University Library,
203 Igbinedion University, Okada.
204</font>
205
206"""
207        return
208
209    def render(self):
210        studentview = StudentBasePDFFormPage(self.context.student,
211            self.request, self.omit_fields)
212        students_utils = getUtility(IStudentsUtils)
213        return students_utils.renderPDF(
214            self, 'lib_idcard',
215            self.context.student, studentview,
216            omit_fields=self.omit_fields,
217            sigs_in_footer=self._sigsInFooter(),
218            note=self.note)
219
220class CustomStartClearancePage(StartClearancePage):
221    with_ac = False
222
223class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage):
224    grok.require('waeup.payStudent')
225
226class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
227    """Deliver a PDF Admission slip.
228    """
229
230    omit_fields = ('date_of_birth', 'current_level', 'current_mode',
231                   'entry_session')
232
233    @property
234    def session(self):
235        return academic_sessions_vocab.getTerm(
236            self.context.entry_session).title
237
238    @property
239    def level(self):
240        studylevelsource = StudyLevelSource()
241        return studylevelsource.factory.getTitle(
242            self.context['studycourse'].certificate, self.context.current_level)
243
244    @property
245    def label(self):
246        return 'OFFER OF PROVISIONAL ADMISSION \nFOR %s SESSION' % self.session
247
248    @property
249    def pre_text(self):
250        return (
251            'Following your performance in the screening exercise '
252            'for the %s academic session, I am pleased to inform '
253            'you that you have been offered provisional admission into the '
254            'Igbinedion University, Okada as follows:' % self.session)
255
256    @property
257    def post_text(self):
258        return """
259Please note that at the point of registration for your programme of study (course), you will be required to present the following documents: Current UTME result slip, WAEC/NECO (0' Level) result, Birth certificate or sworn affidavit of age, and Health certificate from a recognized Medical Centre.
260
261All credentials (orlginal) will be checked during registration. This admission will be cancelled at any point in time it is found that your claims in the application form are false.
262
263You are required to show evidence of the result / credentials you presented on application for admission.
264
265Fees can be paid using any of the following options:
266
267Fees can be paid through your portal page. INSTRUCTIONS can be found below "FEES PAYMENT PROCEDURE" for the options you have to make your payment, as well as instructions on how to use your preferred payment option. If you choose to use the bank payment option, you can pay at any branch of the following banks through Etranzact platform only: Access Bank, First Bank, Zenith Bank
268
269Kindly note the following:
270
271Fees indicated on the Fee Structure page are valid for the current session only.
272Your Student Id (indicated above) Is your logln to the University portal.
273As an indication of your acceptance of this offer of admission, you should pay a non-refundable Acceptance deposit of 200,000. Further note that the 200,000 deposit is part of the tuition fee for the session. Failure to pay after the expiration of two weeks may lead to forfeiture of admission.
274All fees must be paid in full at the beginning of the session, as basis for accommodation, registration and attendance of lectures. This is the rule for all students at all levels. Install mental payments of not more than two installments, may be allowed under exceptional circumstances.
275Fees once paid are not refundable.
276It is advisable that you keep the original receipts of fees paid and present them on demand.
277
278Accommodation: Accommodation in University hostels is compulsory for every student. No student Is allowed to live outside the hostels. Any student who does so will be expelled from the University.
279
280Food: Food is available in cafeteria on "pay-as-you-eat" basis.
281
282Resumption Date: The University opens for fresh students on Saturday, 28th September, 2020. All newly admitted students are expected to report on that date.
283
284Registration/Orientation Programme: Orientation programme/registration for fresh students will start on Monday, 30th September 2020. Registration ends on 2020-10-30. A late registration fee of N50,000 will be charged after this date. All credentials, O'Level Results, Birth Certificate/Age? Declaration, UTME Result Slip (Original) will be checked during registration. This admission will be cancelled at any point in time it is found that any of your claims in the application form is false.
285
286Transport Facility: The University provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
287
288Kindly note that fresh students are not allowed the use of private vehicles.
289
290Conduct: All students are expected to conduct themselves properly and dress decently on campus, as well as obey all rules and regulations as failure to comply will attract appropriate sanctions.
291
292We wish you a successful academic career In lgbinedion University.
293
294Congratulations!
295
296Friday Benji Bakare Esq.
297Registrar
298registrar@iuokada.edu.ng
29908035902949
300"""
301
302    def render(self):
303        students_utils = getUtility(IStudentsUtils)
304        watermark_path = os.path.join(
305            os.path.dirname(__file__), 'static', 'watermark.pdf')
306        watermark = open(watermark_path, 'rb')
307        file_path = os.path.join(
308            os.path.dirname(__file__), 'static', 'admission_letter.pdf')
309        file = open(file_path, 'rb')
310        mergefiles = [file,]
311        return students_utils.renderPDFAdmissionLetter(self,
312            self.context.student, omit_fields=self.omit_fields,
313            pre_text=self.pre_text, post_text=self.post_text,
314            mergefiles=mergefiles,
315            watermark=watermark)
316
317class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
318    """ Page to view an online payment ticket. We do not omit provider_amt.
319    """
320    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
321        'gateway_amt', 'thirdparty_amt', 'p_item','p_combi')
322    form_fields[
323        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
324    form_fields[
325        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
326
327class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
328    """Deliver a PDF slip of the context. We do not omit provider_amt.
329    """
330    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
331        'gateway_amt', 'thirdparty_amt', 'p_item',
332        'p_split_data','p_combi')
333    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
334    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
Note: See TracBrowser for help on using the repository browser.