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

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

Add admission letter for pg students.

  • Property svn:keywords set to Id
File size: 17.1 KB
RevLine 
[10765]1## $Id: browser.py 16238 2020-09-16 10:26:39Z 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
23from hurry.workflow.interfaces import IWorkflowInfo
[16127]24from waeup.kofa.interfaces import (REQUESTED, IExtFileStore, IKofaUtils,
25    academic_sessions_vocab)
[10765]26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15802]27from waeup.kofa.browser.layout import (
28    action, jsaction, UtilityView, KofaEditFormPage)
[10765]29from waeup.kofa.students.browser import (
30    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
[13062]31    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
[10765]32    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
[16015]33    StartClearancePage, BalancePaymentAddFormPage,
[16127]34    ExportPDFAdmissionSlip,
[10765]35    msave, emit_lock_message)
[15802]36from waeup.kofa.students.interfaces import (
37    IStudentsUtils, ICourseTicket, IStudent)
[16127]38from waeup.kofa.students.vocabularies import StudyLevelSource
[10765]39from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
40from kofacustom.nigeria.students.browser import (
41    NigeriaOnlinePaymentDisplayFormPage,
[15704]42    NigeriaStudentBaseDisplayFormPage,
[10765]43    NigeriaStudentBaseManageFormPage,
44    NigeriaStudentClearanceEditFormPage,
45    NigeriaOnlinePaymentAddFormPage,
[13062]46    NigeriaExportPDFPaymentSlip,
47    NigeriaExportPDFClearanceSlip,
[15696]48    NigeriaExportPDFCourseRegistrationSlip,
[15704]49    NigeriaStudentBaseEditFormPage,
[15722]50    NigeriaBedTicketAddPage,
[15999]51    NigeriaAccommodationManageFormPage,
52    NigeriaAccommodationDisplayFormPage,
[10765]53    )
54
[15563]55from kofacustom.iuokada.students.interfaces import (
[10765]56    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
[15859]57    ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent)
[15563]58from kofacustom.iuokada.interfaces import MessageFactory as _
[10765]59
[15704]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(
[15870]70        'student_id', 'adm_code', 'suspended',
71        'financially_cleared_by', 'financial_clearance_date')
[15704]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
[15696]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    #            )
[15720]98    #    return ()
99
[15999]100class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
101    """ Page to view bed tickets.
102    """
103    with_hostel_selection = True
104
[15722]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
[15720]111class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
112    """ Page to add a bed ticket
113    """
114    with_ac = False
[15802]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')
[15805]122    grok.require('waeup.manageStudent')
[15802]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):
[15859]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(),
[15937]218            note=self.note)
219
220class CustomStartClearancePage(StartClearancePage):
[16015]221    with_ac = False
222
223class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage):
[16127]224    grok.require('waeup.payStudent')
225
226class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
227    """Deliver a PDF Admission slip.
228    """
229
[16238]230    omit_fields = ('date_of_birth',
231                   #'current_level',
232                   'current_mode',
233                   #'entry_session'
234                   )
[16127]235
236    @property
237    def session(self):
238        return academic_sessions_vocab.getTerm(
239            self.context.entry_session).title
240
241    @property
242    def level(self):
243        studylevelsource = StudyLevelSource()
244        return studylevelsource.factory.getTitle(
245            self.context['studycourse'].certificate, self.context.current_level)
246
247    @property
248    def label(self):
249        return 'OFFER OF PROVISIONAL ADMISSION \nFOR %s SESSION' % self.session
250
251    @property
[16238]252    def pre_text_ug(self):
[16127]253        return (
254            'Following your performance in the screening exercise '
255            'for the %s academic session, I am pleased to inform '
256            'you that you have been offered provisional admission into the '
257            'Igbinedion University, Okada as follows:' % self.session)
258
259    @property
[16238]260    def pre_text_pg(self):
261        return (
262            'I am pleased to inform you that your application for admission'
263            ' into the Igbinedion University, Okada was successful. You have'
264            ' been admitted as follows:')
265
266    @property
267    def post_text_ug(self):
[16127]268        return """
[16163]269Please 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]270
[16163]271All 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.
[16127]272
[16163]273You are required to show evidence of the result / credentials you presented on application for admission.
[16127]274
[16128]275Fees can be paid using any of the following options:
[16127]276
[16163]277Fees 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]278
279Kindly note the following:
280
[16163]281Fees indicated on the Fee Structure page are valid for the current session only.
282Your Student Id (indicated above) Is your logln to the University portal.
283As 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.
284All 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.
285Fees once paid are not refundable.
286It is advisable that you keep the original receipts of fees paid and present them on demand.
[16127]287
[16163]288Accommodation: 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]289
290Food: Food is available in cafeteria on "pay-as-you-eat" basis.
291
[16237]292Resumption Date: The University opens for fresh students on Saturday, 26th September, 2020. All newly admitted students are expected to report on that date.
[16127]293
[16163]294Registration/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.
[16127]295
[16163]296Transport Facility: The University provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
[16127]297
298Kindly note that fresh students are not allowed the use of private vehicles.
299
300Conduct: 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.
301
[16163]302We wish you a successful academic career In lgbinedion University.
[16127]303
304Congratulations!
305
[16163]306Friday Benji Bakare Esq.
307Registrar
308registrar@iuokada.edu.ng
30908035902949
[16127]310"""
311
[16238]312    @property
313    def post_text_pg(self):
314        return """
3151. Details of your programme will be made available to you by the Head of your Department on your arrival at the Igbinedion University.
316
3172. 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.
318
3193. If you accept this offer of admission upon the conditions above, you should please:
320
321(a) Complete the enclosed Acceptance Form of Provisional Offer of Admission in duplicate and send  by registered mail or by hand to the
322
323Secretary
324School of Postgraduate Studies and Research
325Igbinedion University,
326P.M.B. 0006,
327Benin City, Edo State,
328Nigeria
329
330(b)     Forward the following along with the Acceptance Form of Provisional Offer of Admission.
331
332(i) A non-refundable deposit of N100,000.00 (One Hundred Thousand Naira Only) which is part of the School fees: Payable Online.
333
334(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.
335
3364. The following will be required for Registration:
337
338(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.
339
340(b) The original copies of all credentials listed in your application form (including NYSC discharge/exemption certificate) should be brought for sighting.
341
3425. 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.
343
3446. Please find attached:
345
346(a) A copy of School fees Regime
347(b) A copy of Acceptance Forms
348
3497. Note:
350
351(a) All Tuition fees are to be paid online
352(b) Post-graduate dues and other charges are to be paid into ABC Microfinance Bank Okada, Account No: 30125
353
3548.  CONGRATULATIONS!!!
355
356Yours faithfully,
357
358Mr. Olaoke, Olasoji Oluwole
359Secretary, School of Postgraduate Studies & Research
360"""
361
[16127]362    def render(self):
363        students_utils = getUtility(IStudentsUtils)
[16160]364        watermark_path = os.path.join(
365            os.path.dirname(__file__), 'static', 'watermark.pdf')
366        watermark = open(watermark_path, 'rb')
[16238]367        if self.context.is_postgrad:
368            file_path = os.path.join(
369                os.path.dirname(__file__), 'static', 'admission_letter_pg.pdf')
370            file = open(file_path, 'rb')
371            mergefiles = [file,]
372            return students_utils.renderPDFAdmissionLetter(self,
373                self.context.student, omit_fields=self.omit_fields,
374                pre_text=self.pre_text_pg, post_text=self.post_text_pg,
375                mergefiles=mergefiles,
376                watermark=watermark)
[16160]377        file_path = os.path.join(
[16238]378            os.path.dirname(__file__), 'static', 'admission_letter_ug.pdf')
[16160]379        file = open(file_path, 'rb')
380        mergefiles = [file,]
[16127]381        return students_utils.renderPDFAdmissionLetter(self,
382            self.context.student, omit_fields=self.omit_fields,
[16238]383            pre_text=self.pre_text_ug, post_text=self.post_text_ug,
[16180]384            mergefiles=mergefiles,
385            watermark=watermark)
[16233]386
387class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
388    """ Page to view an online payment ticket. We do not omit provider_amt.
389    """
390    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
391        'gateway_amt', 'thirdparty_amt', 'p_item','p_combi')
392    form_fields[
393        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
394    form_fields[
395        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
396
397class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
398    """Deliver a PDF slip of the context. We do not omit provider_amt.
399    """
400    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
401        'gateway_amt', 'thirdparty_amt', 'p_item',
402        'p_split_data','p_combi')
403    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
404    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
Note: See TracBrowser for help on using the repository browser.