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

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

Remove 'provider_amt' on pages and slips.

  • Property svn:keywords set to Id
File size: 20.7 KB
RevLine 
[10765]1## $Id: browser.py 16285 2020-10-18 17:02:45Z 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
[16160]19import os
[10765]20from zope.i18n import translate
21from zope.schema.interfaces import ConstraintNotSatisfied
22from zope.component import getUtility
[16249]23from zope.formlib.textwidgets import BytesDisplayWidget
[10765]24from hurry.workflow.interfaces import IWorkflowInfo
[16259]25from waeup.kofa.interfaces import (REQUESTED, ADMITTED, CLEARANCE,
26    IExtFileStore, IKofaUtils, academic_sessions_vocab)
[10765]27from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15802]28from waeup.kofa.browser.layout import (
29    action, jsaction, UtilityView, KofaEditFormPage)
[10765]30from waeup.kofa.students.browser import (
31    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
[13062]32    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
[10765]33    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
[16015]34    StartClearancePage, BalancePaymentAddFormPage,
[16252]35    ExportPDFAdmissionSlip, ExportPDFPersonalDataSlip,
[10765]36    msave, emit_lock_message)
[15802]37from waeup.kofa.students.interfaces import (
38    IStudentsUtils, ICourseTicket, IStudent)
[16127]39from waeup.kofa.students.vocabularies import StudyLevelSource
[10765]40from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
41from kofacustom.nigeria.students.browser import (
42    NigeriaOnlinePaymentDisplayFormPage,
[15704]43    NigeriaStudentBaseDisplayFormPage,
[10765]44    NigeriaStudentBaseManageFormPage,
45    NigeriaStudentClearanceEditFormPage,
46    NigeriaOnlinePaymentAddFormPage,
[13062]47    NigeriaExportPDFPaymentSlip,
48    NigeriaExportPDFClearanceSlip,
[15696]49    NigeriaExportPDFCourseRegistrationSlip,
[15704]50    NigeriaStudentBaseEditFormPage,
[15722]51    NigeriaBedTicketAddPage,
[15999]52    NigeriaAccommodationManageFormPage,
53    NigeriaAccommodationDisplayFormPage,
[16249]54    NigeriaStudentPersonalManageFormPage,
55    NigeriaStudentPersonalEditFormPage,
56    NigeriaStudentPersonalDisplayFormPage
[10765]57    )
[15563]58from kofacustom.iuokada.students.interfaces import (
[10765]59    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
[16249]60    ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent,
61    ICustomStudentPersonal, ICustomStudentPersonalEdit)
[15563]62from kofacustom.iuokada.interfaces import MessageFactory as _
[10765]63
[15704]64class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage):
65    """ Page to display student base data
66    """
67    form_fields = grok.AutoFields(ICustomStudentBase).omit(
68        'password', 'suspended', 'suspended_comment', 'flash_notice')
69
70class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage):
71    """ View to manage student base data
72    """
73    form_fields = grok.AutoFields(ICustomStudentBase).omit(
[15870]74        'student_id', 'adm_code', 'suspended',
75        'financially_cleared_by', 'financial_clearance_date')
[15704]76
77class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
78    """ View to edit student base data
79    """
[16259]80    @property
81    def form_fields(self):
82        form_fields = grok.AutoFields(ICustomStudentBase).select(
[16272]83            'email', 'email2', 'parents_email', 'phone',)
[16259]84        if not self.context.state in (ADMITTED, CLEARANCE):
85            form_fields['parents_email'].for_display = True
86        return form_fields
[15704]87
[15696]88class CustomExportPDFCourseRegistrationSlip(
89    NigeriaExportPDFCourseRegistrationSlip):
90    """Deliver a PDF slip of the context.
91    """
92
93    def _signatures(self):
94        return (
95                ['Student Signature'],
96                ['HoD / Course Adviser Signature'],
97                ['College Officer Signature'],
98                ['Dean Signature']
99                )
100
101    #def _sigsInFooter(self):
102    #    return (_('Student'),
103    #            _('HoD / Course Adviser'),
104    #            _('College Officer'),
105    #            _('Dean'),
106    #            )
[15720]107    #    return ()
108
[16249]109class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
110    """ Page to display student personal data
111    """
112    form_fields = grok.AutoFields(ICustomStudentPersonal)
113    form_fields['perm_address'].custom_widget = BytesDisplayWidget
114    form_fields['postal_address'].custom_widget = BytesDisplayWidget
115    form_fields['hostel_address'].custom_widget = BytesDisplayWidget
116    form_fields['father_address'].custom_widget = BytesDisplayWidget
117    form_fields['mother_address'].custom_widget = BytesDisplayWidget
118    form_fields['guardian_address'].custom_widget = BytesDisplayWidget
119    form_fields[
120        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
121
122
123class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
124    """ Page to edit personal data
125    """
[16259]126    form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit(
127        'personal_updated')
[16249]128
[16258]129    def update(self):
130        if not self.context.is_fresh:
131            self.flash('Not allowed.', type="danger")
132            self.redirect(self.url(self.context))
133            return
[16264]134        minamount = 200000
135        if not self.context.minimumFreshStudentPayments(minamount):
136            self.flash('Please make required payments first '
137                       '(at least in the amount of %s Naira).' % minamount,
138                       type="warning")
139            self.redirect(self.url(self.context, 'view_personal'))
140            return
[16258]141        super(CustomStudentPersonalEditFormPage, self).update()
142        return
143
144
[16249]145class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
146    """ Page to edit personal data
147    """
148    form_fields = grok.AutoFields(ICustomStudentPersonal)
149    form_fields['personal_updated'].for_display = True
150    form_fields[
151        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
152
[16252]153class CustomExportPDFPersonalDataSlip(ExportPDFPersonalDataSlip):
154    """Deliver a PDF base and personal data slip.
155    """
156    omit_fields = (
157        'phone', 'email',
158        'suspended',
159        'adm_code', 'suspended_comment',
160        'current_level',
161        'flash_notice', 'entry_session',
162        'parents_email')
163
164    form_fields = grok.AutoFields(ICustomStudentPersonal)
165
[16255]166    def render(self):
167        studentview = StudentBasePDFFormPage(self.context.student,
168            self.request, self.omit_fields)
169        students_utils = getUtility(IStudentsUtils)
170
171        watermark_path = os.path.join(
172            os.path.dirname(__file__), 'static', 'watermark.pdf')
173        watermark = open(watermark_path, 'rb')
174        file_path = os.path.join(
175            os.path.dirname(__file__), 'static', 'biodataPage2.pdf')
176        file = open(file_path, 'rb')
177        mergefiles = [file,]
178        return students_utils.renderPDF(
179            self, 'personal_slip.pdf',
180            self.context.student, studentview,
181            omit_fields=self.omit_fields,
182            mergefiles=mergefiles,
183            watermark=watermark)
184
[15999]185class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
186    """ Page to view bed tickets.
187    """
188    with_hostel_selection = True
189
[15722]190class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
191    """ Page to manage bed tickets.
192    This manage form page is for both students and students officers.
193    """
194    with_hostel_selection = True
195
[15720]196class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
197    """ Page to add a bed ticket
198    """
199    with_ac = False
[15802]200    with_bedselection = True
201
202class StudentGetMatricNumberPage(UtilityView, grok.View):
203    """ Construct and set the matriculation number.
204    """
205    grok.context(IStudent)
206    grok.name('get_matric_number')
[15805]207    grok.require('waeup.manageStudent')
[15802]208
209    def update(self):
210        students_utils = getUtility(IStudentsUtils)
211        msg, mnumber = students_utils.setMatricNumber(self.context)
212        if msg:
213            self.flash(msg, type="danger")
214        else:
215            self.flash(_('Matriculation number %s assigned.' % mnumber))
216            self.context.writeLogMessage(self, '%s assigned' % mnumber)
217        self.redirect(self.url(self.context))
218        return
219
220    def render(self):
[15859]221        return
222
223class SwitchLibraryAccessView(UtilityView, grok.View):
224    """ Switch the library attribute
225    """
226    grok.context(ICustomStudent)
227    grok.name('switch_library_access')
228    grok.require('waeup.switchLibraryAccess')
229
230    def update(self):
231        if self.context.library:
232            self.context.library = False
233            self.context.writeLogMessage(self, 'library access disabled')
234            self.flash(_('Library access disabled'))
235        else:
236            self.context.library = True
237            self.context.writeLogMessage(self, 'library access enabled')
238            self.flash(_('Library access enabled'))
239        self.redirect(self.url(self.context))
240        return
241
242    def render(self):
243        return
244
245class ExportLibIdCard(UtilityView, grok.View):
246    """Deliver an id card for the library.
247    """
248    grok.context(ICustomStudent)
249    grok.name('lib_idcard.pdf')
250    grok.require('waeup.viewStudent')
251    prefix = 'form'
252
253    label = u"Library Clearance"
254
255    omit_fields = (
256        'suspended', 'email', 'phone',
257        'adm_code', 'suspended_comment',
258        'date_of_birth',
259        'current_mode', 'certificate',
260        'entry_session',
261        'flash_notice')
262
263    form_fields = []
264
265    def _sigsInFooter(self):
266        isStudent = getattr(
267            self.request.principal, 'user_type', None) == 'student'
268        if isStudent:
269            return ''
270        return (_("Date, Reader's Signature"),
271                _("Date, Circulation Librarian's Signature"),
272                )
273
274    def update(self):
275        if not self.context.library:
276            self.flash(_('Forbidden!'), type="danger")
277            self.redirect(self.url(self.context))
278        return
279
280    @property
281    def note(self):
282        return """
283<br /><br /><br /><br /><font size='12'>
284This is to certify that the bearer whose photograph and other details appear
285 overleaf is a registered user of the <b>University Library</b>.
286 The card is not transferable. A replacement fee is charged for a loss,
287 mutilation or otherwise. If found, please, return to the University Library,
288 Igbinedion University, Okada.
289</font>
290
291"""
292        return
293
294    def render(self):
295        studentview = StudentBasePDFFormPage(self.context.student,
296            self.request, self.omit_fields)
297        students_utils = getUtility(IStudentsUtils)
298        return students_utils.renderPDF(
299            self, 'lib_idcard',
300            self.context.student, studentview,
301            omit_fields=self.omit_fields,
302            sigs_in_footer=self._sigsInFooter(),
[15937]303            note=self.note)
304
305class CustomStartClearancePage(StartClearancePage):
[16015]306    with_ac = False
307
308class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage):
[16127]309    grok.require('waeup.payStudent')
310
311class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
312    """Deliver a PDF Admission slip.
313    """
314
[16238]315    omit_fields = ('date_of_birth',
316                   #'current_level',
317                   'current_mode',
318                   #'entry_session'
319                   )
[16127]320
321    @property
322    def session(self):
323        return academic_sessions_vocab.getTerm(
324            self.context.entry_session).title
325
326    @property
327    def level(self):
328        studylevelsource = StudyLevelSource()
329        return studylevelsource.factory.getTitle(
330            self.context['studycourse'].certificate, self.context.current_level)
331
332    @property
333    def label(self):
334        return 'OFFER OF PROVISIONAL ADMISSION \nFOR %s SESSION' % self.session
335
336    @property
[16238]337    def pre_text_ug(self):
[16127]338        return (
339            'Following your performance in the screening exercise '
340            'for the %s academic session, I am pleased to inform '
341            'you that you have been offered provisional admission into the '
342            'Igbinedion University, Okada as follows:' % self.session)
343
344    @property
[16238]345    def pre_text_pg(self):
346        return (
347            'I am pleased to inform you that your application for admission'
348            ' into the Igbinedion University, Okada was successful. You have'
349            ' been admitted as follows:')
350
351    @property
352    def post_text_ug(self):
[16127]353        return """
[16241]354Please 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.
[16127]355
[16241]356All credentials (original) 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.
[16127]357
[16163]358You are required to show evidence of the result / credentials you presented on application for admission.
[16127]359
[16128]360Fees can be paid using any of the following options:
[16127]361
[16163]362Fees 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
[16127]363
364Kindly note the following:
365
[16163]366Fees indicated on the Fee Structure page are valid for the current session only.
367Your Student Id (indicated above) Is your logln to the University portal.
368As 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.
369All 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.
370Fees once paid are not refundable.
371It is advisable that you keep the original receipts of fees paid and present them on demand.
[16127]372
[16163]373Accommodation: 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.
[16127]374
375Food: Food is available in cafeteria on "pay-as-you-eat" basis.
376
[16260]377Resumption Date: The University opens for fresh students with online registration starting from Monday 28th September, 2020. The date for physical resumption is 7th November, 2020.
[16127]378
[16260]379Registration/Orientation Programme: Orientation programme/registration for fresh students will start on Monday, 9th November 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.
[16127]380
[16163]381Transport Facility: The University provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
[16127]382
383Kindly note that fresh students are not allowed the use of private vehicles.
384
385Conduct: 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.
386
[16241]387We wish you a successful academic career in Igbinedion University.
[16127]388
389Congratulations!
390
[16263]391
392
393<img src="${signature_benji_img_path}" valign="-20" height="38" width="86" />
394
[16163]395Friday Benji Bakare Esq.
396Registrar
397registrar@iuokada.edu.ng
39808035902949
[16127]399"""
400
[16238]401    @property
402    def post_text_pg(self):
403        return """
4041. Details of your programme will be made available to you by the Head of your Department on your arrival at the Igbinedion University.
405
4062. This offer is conditional upon the confirmation of your qualifications as listed by you in your application form. You will be required to produce the ORIGINAL COPIES of all your certificates for verification during registration. If at any time after admission, it is discovered that you do not possess any of the qualifications upon which this offer of admission was made, you will be required to withdraw from the University.
407
4083. If you accept this offer of admission upon the conditions above, you should please:
409
410(a) Complete the enclosed Acceptance Form of Provisional Offer of Admission in duplicate and send  by registered mail or by hand to the
411
412Secretary
413School of Postgraduate Studies and Research
414Igbinedion University,
415P.M.B. 0006,
416Benin City, Edo State,
417Nigeria
418
419(b)     Forward the following along with the Acceptance Form of Provisional Offer of Admission.
420
421(i) A non-refundable deposit of N100,000.00 (One Hundred Thousand Naira Only) which is part of the School fees: Payable Online.
422
423(ii) Four recent passport-size photograph of yourself with your full-names (surname first in BLOCK LETTERS) written on the reverse side of the photograph and pinned to the Acceptance Form.
424
4254. The following will be required for Registration:
426
427(a) A medical examination to be conducted by an approved medical practitioner. On your arrival at the Igbinedion University, you should submit the enclosed Igbinedion University Medical Examination Form duly completed and signed by an approved medical practitioner together with your chest X-ray film to Director of Health Service at the Igbinedion University, Okada.
428
429(b) The original copies of all credentials listed in your application form (including NYSC discharge/exemption certificate) should be brought for sighting.
430
4315. You are required to pay the necessary fees and register for your degree programme not later than three weeks from the beginning of the Academic Session. Late registration may be allowed during an additional period of five weeks on payment of a late registration fees. Please note that you will be allowed to register after two months have elapsed from the beginning of the sessions.
432
4336. Please find attached:
434
435(a) A copy of School fees Regime
436(b) A copy of Acceptance Forms
437
4387. Note:
439
440(a) All Tuition fees are to be paid online
441(b) Post-graduate dues and other charges are to be paid into ABC Microfinance Bank Okada, Account No: 30125
442
4438.  CONGRATULATIONS!!!
444
445Yours faithfully,
446
447Mr. Olaoke, Olasoji Oluwole
448Secretary, School of Postgraduate Studies & Research
449"""
450
[16127]451    def render(self):
452        students_utils = getUtility(IStudentsUtils)
[16160]453        watermark_path = os.path.join(
454            os.path.dirname(__file__), 'static', 'watermark.pdf')
455        watermark = open(watermark_path, 'rb')
[16238]456        if self.context.is_postgrad:
457            file_path = os.path.join(
458                os.path.dirname(__file__), 'static', 'admission_letter_pg.pdf')
459            file = open(file_path, 'rb')
460            mergefiles = [file,]
461            return students_utils.renderPDFAdmissionLetter(self,
462                self.context.student, omit_fields=self.omit_fields,
463                pre_text=self.pre_text_pg, post_text=self.post_text_pg,
464                mergefiles=mergefiles,
465                watermark=watermark)
[16160]466        file_path = os.path.join(
[16238]467            os.path.dirname(__file__), 'static', 'admission_letter_ug.pdf')
[16160]468        file = open(file_path, 'rb')
469        mergefiles = [file,]
[16127]470        return students_utils.renderPDFAdmissionLetter(self,
471            self.context.student, omit_fields=self.omit_fields,
[16238]472            pre_text=self.pre_text_ug, post_text=self.post_text_ug,
[16180]473            mergefiles=mergefiles,
474            watermark=watermark)
[16233]475
476class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
477    """ Page to view an online payment ticket. We do not omit provider_amt.
478    """
479    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[16285]480        'gateway_amt', 'thirdparty_amt', 'p_item','p_combi', 'provider_amt')
[16233]481    form_fields[
482        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
483    form_fields[
484        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
485
486class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
487    """Deliver a PDF slip of the context. We do not omit provider_amt.
488    """
489    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
490        'gateway_amt', 'thirdparty_amt', 'p_item',
[16285]491        'p_split_data','p_combi', 'provider_amt')
[16233]492    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
493    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
Note: See TracBrowser for help on using the repository browser.