## $Id: browser.py 16486 2021-05-20 05:52:54Z henrik $
##
## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
import grok
import os
from zope.i18n import translate
from zope.schema.interfaces import ConstraintNotSatisfied
from zope.component import getUtility
from zope.formlib.textwidgets import BytesDisplayWidget
from hurry.workflow.interfaces import IWorkflowInfo
from waeup.kofa.interfaces import (REQUESTED, ADMITTED, CLEARANCE,
IExtFileStore, IKofaUtils, academic_sessions_vocab)
from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
from waeup.kofa.browser.layout import (
action, jsaction, UtilityView, KofaEditFormPage)
from waeup.kofa.students.browser import (
StudyLevelEditFormPage, StudyLevelDisplayFormPage,
StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
StartClearancePage, BalancePaymentAddFormPage,
ExportPDFAdmissionSlip, ExportPDFPersonalDataSlip,
msave, emit_lock_message)
from waeup.kofa.students.interfaces import (
IStudentsUtils, ICourseTicket, IStudent)
from waeup.kofa.students.vocabularies import StudyLevelSource
from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
from kofacustom.nigeria.students.browser import (
NigeriaOnlinePaymentDisplayFormPage,
NigeriaStudentBaseDisplayFormPage,
NigeriaStudentBaseManageFormPage,
NigeriaStudentClearanceEditFormPage,
NigeriaOnlinePaymentAddFormPage,
NigeriaExportPDFPaymentSlip,
NigeriaExportPDFClearanceSlip,
NigeriaExportPDFCourseRegistrationSlip,
NigeriaStudentBaseEditFormPage,
NigeriaBedTicketAddPage,
NigeriaAccommodationManageFormPage,
NigeriaAccommodationDisplayFormPage,
NigeriaStudentPersonalManageFormPage,
NigeriaStudentPersonalEditFormPage,
NigeriaStudentPersonalDisplayFormPage
)
from kofacustom.iuokada.students.interfaces import (
ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent,
ICustomStudentPersonal, ICustomStudentPersonalEdit)
from kofacustom.iuokada.interfaces import MessageFactory as _
class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage):
""" Page to display student base data
"""
form_fields = grok.AutoFields(ICustomStudentBase).omit(
'password', 'suspended', 'suspended_comment', 'flash_notice')
class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage):
""" View to manage student base data
"""
form_fields = grok.AutoFields(ICustomStudentBase).omit(
'student_id', 'adm_code', 'suspended',
'financially_cleared_by', 'financial_clearance_date')
class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
""" View to edit student base data
"""
@property
def form_fields(self):
form_fields = grok.AutoFields(ICustomStudentBase).select(
'email', 'email2', 'parents_email', 'phone',)
if not self.context.state in (ADMITTED, CLEARANCE):
form_fields['parents_email'].for_display = True
return form_fields
class CustomExportPDFCourseRegistrationSlip(
NigeriaExportPDFCourseRegistrationSlip):
"""Deliver a PDF slip of the context.
"""
def _signatures(self):
return (
['Student Signature'],
['HoD / Course Adviser Signature'],
['College Officer Signature'],
['Dean Signature']
)
#def _sigsInFooter(self):
# return (_('Student'),
# _('HoD / Course Adviser'),
# _('College Officer'),
# _('Dean'),
# )
# return ()
class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
""" Page to display student personal data
"""
form_fields = grok.AutoFields(ICustomStudentPersonal)
form_fields['perm_address'].custom_widget = BytesDisplayWidget
form_fields['postal_address'].custom_widget = BytesDisplayWidget
form_fields['hostel_address'].custom_widget = BytesDisplayWidget
form_fields['father_address'].custom_widget = BytesDisplayWidget
form_fields['mother_address'].custom_widget = BytesDisplayWidget
form_fields['guardian_address'].custom_widget = BytesDisplayWidget
form_fields[
'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
""" Page to edit personal data
"""
form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit(
'personal_updated')
def update(self):
#if not self.context.is_fresh:
# self.flash('Not allowed.', type="danger")
# self.redirect(self.url(self.context))
# return
if not self.context.minimumStudentPayments():
self.flash('Please make 40% of your tution fee payments first.',
type="warning")
self.redirect(self.url(self.context, 'view_personal'))
return
super(CustomStudentPersonalEditFormPage, self).update()
return
class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
""" Page to manage personal data
"""
form_fields = grok.AutoFields(ICustomStudentPersonal)
form_fields['personal_updated'].for_display = True
form_fields[
'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
class CustomExportPDFPersonalDataSlip(ExportPDFPersonalDataSlip):
"""Deliver a PDF base and personal data slip.
"""
grok.name('course_registration_clearance.pdf')
omit_fields = (
'phone', 'email',
'suspended',
'adm_code', 'suspended_comment',
'current_level',
'flash_notice', 'entry_session',
'parents_email')
form_fields = grok.AutoFields(ICustomStudentPersonal)
def _signatures(self):
return ([('I certify that the above named student has satisfied the financial requirements for registration.', 'Name and Signature of Bursary Staff', '
')],
[('I certify that the credentials of the student have been screened by me and the student is hereby cleared.', 'Name and Signature of Registry Staff', '
')],
[('I certify that the above named student has registered with the Library.', 'Name and Signature of Library Staff', '
')],
[('I certify that the above named student has been registered with the college. ', 'Name and Signature of College Officer', '
')],
[('I certify that the above named student has completed his/her ICT registration. ', 'Name and Signature of ICT Staff', '
')],
[('Eligibility/Congratulation Station', 'Name and Signature of Registrar', '')],
)
@property
def tabletitle(self):
portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
tabletitle = []
session = self.context.student.current_session
tabletitle.append('_PB_Successful %s/%s Session Payments' %(session, session+1))
return tabletitle
def render(self):
if not self.context.minimumStudentPayments():
self.redirect(self.url(self.context))
return
studentview = StudentBasePDFFormPage(self.context.student,
self.request, self.omit_fields)
students_utils = getUtility(IStudentsUtils)
portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
P_ID = translate(_('Payment Id'), 'waeup.kofa', target_language=portal_language)
#CD = translate(_('Creation Date'), 'waeup.kofa', target_language=portal_language)
PD = translate(_('Payment Date'), 'waeup.kofa', target_language=portal_language)
CAT = translate(_('Payment Category'), 'waeup.kofa', target_language=portal_language)
ITEM = translate(_('Payment Item'), 'waeup.kofa', target_language=portal_language)
AMT = translate(_('Amount (Naira)'), 'waeup.kofa', target_language=portal_language)
SSS = translate(_('Payment Session'), 'waeup.kofa', target_language=portal_language)
tabledata = []
tableheader = []
tabledata.append(sorted(
[value for value in self.context['payments'].values()
if value.p_state in ('paid', 'waived', 'scholarship')
and value.p_session >= value.student.current_session],
key=lambda value: value.p_session))
tableheader.append([(P_ID,'p_id', 4.2),
#(CD,'creation_date', 3),
(PD,'formatted_p_date', 3),
(CAT,'category', 3),
(ITEM, 'p_item', 3),
(AMT, 'amount_auth', 2),
(SSS, 'p_session', 2),
])
#watermark_path = os.path.join(
# os.path.dirname(__file__), 'static', 'watermark.pdf')
#watermark = open(watermark_path, 'rb')
#file_path = os.path.join(
# os.path.dirname(__file__), 'static', 'biodataPage2.pdf')
#file = open(file_path, 'rb')
#mergefiles = [file,]
return students_utils.renderPDF(
self, 'course_registration_clearance.pdf',
self.context.student, studentview,
omit_fields=self.omit_fields,
signatures=self._signatures(),
tableheader=tableheader,
tabledata=tabledata,
pagebreak=True,
# mergefiles=mergefiles,
# watermark=watermark
)
class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
""" Page to view bed tickets.
"""
with_hostel_selection = True
class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
""" Page to manage bed tickets.
This manage form page is for both students and students officers.
"""
with_hostel_selection = True
class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
""" Page to add a bed ticket
"""
with_ac = False
with_bedselection = True
class StudentGetMatricNumberPage(UtilityView, grok.View):
""" Construct and set the matriculation number.
"""
grok.context(IStudent)
grok.name('get_matric_number')
grok.require('waeup.manageStudent')
def update(self):
students_utils = getUtility(IStudentsUtils)
msg, mnumber = students_utils.setMatricNumber(self.context)
if msg:
self.flash(msg, type="danger")
else:
self.flash(_('Matriculation number %s assigned.' % mnumber))
self.context.writeLogMessage(self, '%s assigned' % mnumber)
self.redirect(self.url(self.context))
return
def render(self):
return
class SwitchLibraryAccessView(UtilityView, grok.View):
""" Switch the library attribute
"""
grok.context(ICustomStudent)
grok.name('switch_library_access')
grok.require('waeup.switchLibraryAccess')
def update(self):
if self.context.library:
self.context.library = False
self.context.writeLogMessage(self, 'library access disabled')
self.flash(_('Library access disabled'))
else:
self.context.library = True
self.context.writeLogMessage(self, 'library access enabled')
self.flash(_('Library access enabled'))
self.redirect(self.url(self.context))
return
def render(self):
return
class ExportLibIdCard(UtilityView, grok.View):
"""Deliver an id card for the library.
"""
grok.context(ICustomStudent)
grok.name('lib_idcard.pdf')
grok.require('waeup.viewStudent')
prefix = 'form'
label = u"Library Clearance"
omit_fields = (
'suspended', 'email', 'phone',
'adm_code', 'suspended_comment',
'date_of_birth',
'current_mode', 'certificate',
'entry_session',
'flash_notice')
form_fields = []
def _sigsInFooter(self):
isStudent = getattr(
self.request.principal, 'user_type', None) == 'student'
if isStudent:
return ''
return (_("Date, Reader's Signature"),
_("Date, Circulation Librarian's Signature"),
)
def update(self):
if not self.context.library:
self.flash(_('Forbidden!'), type="danger")
self.redirect(self.url(self.context))
return
@property
def note(self):
return """
This is to certify that the bearer whose photograph and other details appear
overleaf is a registered user of the University Library.
The card is not transferable. A replacement fee is charged for a loss,
mutilation or otherwise. If found, please, return to the University Library,
Igbinedion University, Okada.
"""
return
def render(self):
studentview = StudentBasePDFFormPage(self.context.student,
self.request, self.omit_fields)
students_utils = getUtility(IStudentsUtils)
return students_utils.renderPDF(
self, 'lib_idcard',
self.context.student, studentview,
omit_fields=self.omit_fields,
sigs_in_footer=self._sigsInFooter(),
note=self.note)
class CustomStartClearancePage(StartClearancePage):
with_ac = False
class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage):
grok.require('waeup.payStudent')
class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
"""Deliver a PDF Admission slip.
"""
omit_fields = ('date_of_birth',
#'current_level',
'current_mode',
#'entry_session'
)
@property
def session(self):
return academic_sessions_vocab.getTerm(
self.context.entry_session).title
@property
def level(self):
studylevelsource = StudyLevelSource()
return studylevelsource.factory.getTitle(
self.context['studycourse'].certificate, self.context.current_level)
@property
def label(self):
return 'OFFER OF PROVISIONAL ADMISSION \nFOR %s SESSION' % self.session
@property
def pre_text_ug(self):
return (
'Following your performance in the screening exercise '
'for the %s academic session, I am pleased to inform '
'you that you have been offered provisional admission into the '
'Igbinedion University, Okada as follows:' % self.session)
@property
def pre_text_pg(self):
return (
'I am pleased to inform you that your application for admission'
' into the Igbinedion University, Okada was successful. You have'
' been admitted as follows:')
@property
def basic_medical_only_text(self):
return"""
Progression to 200 Level MBBS programmes is highly competitive and strictly based on merit/approved quota. Students who are unable to make the cut off point will have the option of joining allied courses such as BSc Nursing, BSc Anatomy, BSc Biochemistry, BSc Physiology, Bachelor of Medical Laboratory Science, including Computer Science and engineering courses at 200 Level provided they have the relevant O/L credits.
"""
@property
def post_text_ug(self):
return """
Please 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.
All 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.
You are required to show evidence of the result / credentials you presented on application for admission.
Fees can be paid using any of the following options:
Fees 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
Kindly note the following:
Fees indicated on the Fee Structure page are valid for the current session only.
Your Student Id (indicated above) Is your logln to the University portal.
As 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.
All 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.
Fees once paid are not refundable.
It is advisable that you keep the original receipts of fees paid and present them on demand.
Accommodation: 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.
Food: Food is available in cafeteria on "pay-as-you-eat" basis.
Resumption Date: The University opens for fresh students with online registration starting from Monday 28th September, 2020. The date for physical resumption is 14th November, 2020.
Registration/Orientation Programme: Orientation programme/registration for fresh students will start on Monday, 16th November 2020. Registration ends on 2020-11-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.
Transport Facility: The University provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
Kindly note that fresh students are not allowed the use of private vehicles.
Conduct: 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.
We wish you a successful academic career in Igbinedion University.
Congratulations!
Friday Benji Bakare Esq.
Registrar
registrar@iuokada.edu.ng
08035902949
"""
@property
def post_text_pg(self):
return """
1. Details of your programme will be made available to you by the Head of your Department on your arrival at the Igbinedion University.
2. 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.
3. If you accept this offer of admission upon the conditions above, you should please:
(a) Complete the enclosed Acceptance Form of Provisional Offer of Admission in duplicate and send by registered mail or by hand to the
Secretary
School of Postgraduate Studies and Research
Igbinedion University,
P.M.B. 0006,
Benin City, Edo State,
Nigeria
(b) Forward the following along with the Acceptance Form of Provisional Offer of Admission.
(i) A non-refundable deposit of N100,000.00 (One Hundred Thousand Naira Only) which is part of the School fees: Payable Online.
(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.
4. The following will be required for Registration:
(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.
(b) The original copies of all credentials listed in your application form (including NYSC discharge/exemption certificate) should be brought for sighting.
5. 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.
6. Please find attached:
(a) A copy of School fees Regime
(b) A copy of Acceptance Forms
7. Note:
(a) All Tuition fees are to be paid online
(b) Post-graduate dues and other charges are to be paid into ABC Microfinance Bank Okada, Account No: 30125
8. CONGRATULATIONS!!!
Yours faithfully,
Mr. Olaoke, Olasoji Oluwole
Secretary, School of Postgraduate Studies & Research
"""
def render(self):
students_utils = getUtility(IStudentsUtils)
watermark_path = os.path.join(
os.path.dirname(__file__), 'static', 'watermark.pdf')
watermark = open(watermark_path, 'rb')
if self.context.is_postgrad:
file_path = os.path.join(
os.path.dirname(__file__), 'static', 'admission_letter_pg.pdf')
file = open(file_path, 'rb')
mergefiles = [file,]
return students_utils.renderPDFAdmissionLetter(self,
self.context.student, omit_fields=self.omit_fields,
pre_text=self.pre_text_pg, post_text=self.post_text_pg,
mergefiles=mergefiles,
watermark=watermark)
file_path = os.path.join(
os.path.dirname(__file__), 'static', 'admission_letter_ug.pdf')
file = open(file_path, 'rb')
mergefiles = [file,]
if self.context.certcode == 'BBMS' and self.context.current_level == 100:
post_text = self.basic_medical_only_text + self.post_text_ug
else:
post_text = self.post_text_ug
return students_utils.renderPDFAdmissionLetter(self,
self.context.student, omit_fields=self.omit_fields,
pre_text=self.pre_text_ug, post_text=post_text,
mergefiles=mergefiles,
watermark=watermark)
class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
""" Page to view an online payment ticket. We do not omit provider_amt.
"""
form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
'gateway_amt', 'thirdparty_amt', 'p_item','p_combi', 'provider_amt')
form_fields[
'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
form_fields[
'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
"""Deliver a PDF slip of the context. We do not omit provider_amt.
"""
form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
'gateway_amt', 'thirdparty_amt', 'p_item',
'p_split_data','p_combi', 'provider_amt')
form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')