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

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

Customite personal data form.

  • Property svn:keywords set to Id
File size: 18.6 KB
Line 
1## $Id: browser.py 16249 2020-09-28 17:37:18Z 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 zope.formlib.textwidgets import BytesDisplayWidget
24from hurry.workflow.interfaces import IWorkflowInfo
25from waeup.kofa.interfaces import (REQUESTED, IExtFileStore, IKofaUtils,
26    academic_sessions_vocab)
27from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
28from waeup.kofa.browser.layout import (
29    action, jsaction, UtilityView, KofaEditFormPage)
30from waeup.kofa.students.browser import (
31    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
32    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
33    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
34    StartClearancePage, BalancePaymentAddFormPage,
35    ExportPDFAdmissionSlip,
36    msave, emit_lock_message)
37from waeup.kofa.students.interfaces import (
38    IStudentsUtils, ICourseTicket, IStudent)
39from waeup.kofa.students.vocabularies import StudyLevelSource
40from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
41from kofacustom.nigeria.students.browser import (
42    NigeriaOnlinePaymentDisplayFormPage,
43    NigeriaStudentBaseDisplayFormPage,
44    NigeriaStudentBaseManageFormPage,
45    NigeriaStudentClearanceEditFormPage,
46    NigeriaOnlinePaymentAddFormPage,
47    NigeriaExportPDFPaymentSlip,
48    NigeriaExportPDFClearanceSlip,
49    NigeriaExportPDFCourseRegistrationSlip,
50    NigeriaStudentBaseEditFormPage,
51    NigeriaBedTicketAddPage,
52    NigeriaAccommodationManageFormPage,
53    NigeriaAccommodationDisplayFormPage,
54    NigeriaStudentPersonalManageFormPage,
55    NigeriaStudentPersonalEditFormPage,
56    NigeriaStudentPersonalDisplayFormPage
57    )
58from kofacustom.iuokada.students.interfaces import (
59    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
60    ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent,
61    ICustomStudentPersonal, ICustomStudentPersonalEdit)
62from kofacustom.iuokada.interfaces import MessageFactory as _
63
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(
74        'student_id', 'adm_code', 'suspended',
75        'financially_cleared_by', 'financial_clearance_date')
76
77class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
78    """ View to edit student base data
79    """
80    form_fields = grok.AutoFields(ICustomStudentBase).select(
81        'email', 'email2', 'parents_email', 'phone',)
82
83class CustomExportPDFCourseRegistrationSlip(
84    NigeriaExportPDFCourseRegistrationSlip):
85    """Deliver a PDF slip of the context.
86    """
87
88    def _signatures(self):
89        return (
90                ['Student Signature'],
91                ['HoD / Course Adviser Signature'],
92                ['College Officer Signature'],
93                ['Dean Signature']
94                )
95
96    #def _sigsInFooter(self):
97    #    return (_('Student'),
98    #            _('HoD / Course Adviser'),
99    #            _('College Officer'),
100    #            _('Dean'),
101    #            )
102    #    return ()
103
104class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
105    """ Page to display student personal data
106    """
107    form_fields = grok.AutoFields(ICustomStudentPersonal)
108    form_fields['perm_address'].custom_widget = BytesDisplayWidget
109    form_fields['postal_address'].custom_widget = BytesDisplayWidget
110    form_fields['hostel_address'].custom_widget = BytesDisplayWidget
111    form_fields['father_address'].custom_widget = BytesDisplayWidget
112    form_fields['mother_address'].custom_widget = BytesDisplayWidget
113    form_fields['guardian_address'].custom_widget = BytesDisplayWidget
114    form_fields[
115        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
116
117
118class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
119    """ Page to edit personal data
120    """
121    form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit('personal_updated')
122
123class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
124    """ Page to edit personal data
125    """
126    form_fields = grok.AutoFields(ICustomStudentPersonal)
127    form_fields['personal_updated'].for_display = True
128    form_fields[
129        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
130
131class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
132    """ Page to view bed tickets.
133    """
134    with_hostel_selection = True
135
136class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
137    """ Page to manage bed tickets.
138    This manage form page is for both students and students officers.
139    """
140    with_hostel_selection = True
141
142class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
143    """ Page to add a bed ticket
144    """
145    with_ac = False
146    with_bedselection = True
147
148class StudentGetMatricNumberPage(UtilityView, grok.View):
149    """ Construct and set the matriculation number.
150    """
151    grok.context(IStudent)
152    grok.name('get_matric_number')
153    grok.require('waeup.manageStudent')
154
155    def update(self):
156        students_utils = getUtility(IStudentsUtils)
157        msg, mnumber = students_utils.setMatricNumber(self.context)
158        if msg:
159            self.flash(msg, type="danger")
160        else:
161            self.flash(_('Matriculation number %s assigned.' % mnumber))
162            self.context.writeLogMessage(self, '%s assigned' % mnumber)
163        self.redirect(self.url(self.context))
164        return
165
166    def render(self):
167        return
168
169class SwitchLibraryAccessView(UtilityView, grok.View):
170    """ Switch the library attribute
171    """
172    grok.context(ICustomStudent)
173    grok.name('switch_library_access')
174    grok.require('waeup.switchLibraryAccess')
175
176    def update(self):
177        if self.context.library:
178            self.context.library = False
179            self.context.writeLogMessage(self, 'library access disabled')
180            self.flash(_('Library access disabled'))
181        else:
182            self.context.library = True
183            self.context.writeLogMessage(self, 'library access enabled')
184            self.flash(_('Library access enabled'))
185        self.redirect(self.url(self.context))
186        return
187
188    def render(self):
189        return
190
191class ExportLibIdCard(UtilityView, grok.View):
192    """Deliver an id card for the library.
193    """
194    grok.context(ICustomStudent)
195    grok.name('lib_idcard.pdf')
196    grok.require('waeup.viewStudent')
197    prefix = 'form'
198
199    label = u"Library Clearance"
200
201    omit_fields = (
202        'suspended', 'email', 'phone',
203        'adm_code', 'suspended_comment',
204        'date_of_birth',
205        'current_mode', 'certificate',
206        'entry_session',
207        'flash_notice')
208
209    form_fields = []
210
211    def _sigsInFooter(self):
212        isStudent = getattr(
213            self.request.principal, 'user_type', None) == 'student'
214        if isStudent:
215            return ''
216        return (_("Date, Reader's Signature"),
217                _("Date, Circulation Librarian's Signature"),
218                )
219
220    def update(self):
221        if not self.context.library:
222            self.flash(_('Forbidden!'), type="danger")
223            self.redirect(self.url(self.context))
224        return
225
226    @property
227    def note(self):
228        return """
229<br /><br /><br /><br /><font size='12'>
230This is to certify that the bearer whose photograph and other details appear
231 overleaf is a registered user of the <b>University Library</b>.
232 The card is not transferable. A replacement fee is charged for a loss,
233 mutilation or otherwise. If found, please, return to the University Library,
234 Igbinedion University, Okada.
235</font>
236
237"""
238        return
239
240    def render(self):
241        studentview = StudentBasePDFFormPage(self.context.student,
242            self.request, self.omit_fields)
243        students_utils = getUtility(IStudentsUtils)
244        return students_utils.renderPDF(
245            self, 'lib_idcard',
246            self.context.student, studentview,
247            omit_fields=self.omit_fields,
248            sigs_in_footer=self._sigsInFooter(),
249            note=self.note)
250
251class CustomStartClearancePage(StartClearancePage):
252    with_ac = False
253
254class CustomBalancePaymentAddFormPage(BalancePaymentAddFormPage):
255    grok.require('waeup.payStudent')
256
257class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
258    """Deliver a PDF Admission slip.
259    """
260
261    omit_fields = ('date_of_birth',
262                   #'current_level',
263                   'current_mode',
264                   #'entry_session'
265                   )
266
267    @property
268    def session(self):
269        return academic_sessions_vocab.getTerm(
270            self.context.entry_session).title
271
272    @property
273    def level(self):
274        studylevelsource = StudyLevelSource()
275        return studylevelsource.factory.getTitle(
276            self.context['studycourse'].certificate, self.context.current_level)
277
278    @property
279    def label(self):
280        return 'OFFER OF PROVISIONAL ADMISSION \nFOR %s SESSION' % self.session
281
282    @property
283    def pre_text_ug(self):
284        return (
285            'Following your performance in the screening exercise '
286            'for the %s academic session, I am pleased to inform '
287            'you that you have been offered provisional admission into the '
288            'Igbinedion University, Okada as follows:' % self.session)
289
290    @property
291    def pre_text_pg(self):
292        return (
293            'I am pleased to inform you that your application for admission'
294            ' into the Igbinedion University, Okada was successful. You have'
295            ' been admitted as follows:')
296
297    @property
298    def post_text_ug(self):
299        return """
300Please 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.
301
302All 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.
303
304You are required to show evidence of the result / credentials you presented on application for admission.
305
306Fees can be paid using any of the following options:
307
308Fees 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
309
310Kindly note the following:
311
312Fees indicated on the Fee Structure page are valid for the current session only.
313Your Student Id (indicated above) Is your logln to the University portal.
314As 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.
315All 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.
316Fees once paid are not refundable.
317It is advisable that you keep the original receipts of fees paid and present them on demand.
318
319Accommodation: 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.
320
321Food: Food is available in cafeteria on "pay-as-you-eat" basis.
322
323Resumption Date: The University opens for fresh students with online registration starting from Monday 28th September, 2020. The date for physical resumption will be communicated soon.
324
325Registration/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.
326
327Transport Facility: The University provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
328
329Kindly note that fresh students are not allowed the use of private vehicles.
330
331Conduct: 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.
332
333We wish you a successful academic career in Igbinedion University.
334
335Congratulations!
336
337Friday Benji Bakare Esq.
338Registrar
339registrar@iuokada.edu.ng
34008035902949
341"""
342
343    @property
344    def post_text_pg(self):
345        return """
3461. Details of your programme will be made available to you by the Head of your Department on your arrival at the Igbinedion University.
347
3482. 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.
349
3503. If you accept this offer of admission upon the conditions above, you should please:
351
352(a) Complete the enclosed Acceptance Form of Provisional Offer of Admission in duplicate and send  by registered mail or by hand to the
353
354Secretary
355School of Postgraduate Studies and Research
356Igbinedion University,
357P.M.B. 0006,
358Benin City, Edo State,
359Nigeria
360
361(b)     Forward the following along with the Acceptance Form of Provisional Offer of Admission.
362
363(i) A non-refundable deposit of N100,000.00 (One Hundred Thousand Naira Only) which is part of the School fees: Payable Online.
364
365(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.
366
3674. The following will be required for Registration:
368
369(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.
370
371(b) The original copies of all credentials listed in your application form (including NYSC discharge/exemption certificate) should be brought for sighting.
372
3735. 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.
374
3756. Please find attached:
376
377(a) A copy of School fees Regime
378(b) A copy of Acceptance Forms
379
3807. Note:
381
382(a) All Tuition fees are to be paid online
383(b) Post-graduate dues and other charges are to be paid into ABC Microfinance Bank Okada, Account No: 30125
384
3858.  CONGRATULATIONS!!!
386
387Yours faithfully,
388
389Mr. Olaoke, Olasoji Oluwole
390Secretary, School of Postgraduate Studies & Research
391"""
392
393    def render(self):
394        students_utils = getUtility(IStudentsUtils)
395        watermark_path = os.path.join(
396            os.path.dirname(__file__), 'static', 'watermark.pdf')
397        watermark = open(watermark_path, 'rb')
398        if self.context.is_postgrad:
399            file_path = os.path.join(
400                os.path.dirname(__file__), 'static', 'admission_letter_pg.pdf')
401            file = open(file_path, 'rb')
402            mergefiles = [file,]
403            return students_utils.renderPDFAdmissionLetter(self,
404                self.context.student, omit_fields=self.omit_fields,
405                pre_text=self.pre_text_pg, post_text=self.post_text_pg,
406                mergefiles=mergefiles,
407                watermark=watermark)
408        file_path = os.path.join(
409            os.path.dirname(__file__), 'static', 'admission_letter_ug.pdf')
410        file = open(file_path, 'rb')
411        mergefiles = [file,]
412        return students_utils.renderPDFAdmissionLetter(self,
413            self.context.student, omit_fields=self.omit_fields,
414            pre_text=self.pre_text_ug, post_text=self.post_text_ug,
415            mergefiles=mergefiles,
416            watermark=watermark)
417
418class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
419    """ Page to view an online payment ticket. We do not omit provider_amt.
420    """
421    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
422        'gateway_amt', 'thirdparty_amt', 'p_item','p_combi')
423    form_fields[
424        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
425    form_fields[
426        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
427
428class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
429    """Deliver a PDF slip of the context. We do not omit provider_amt.
430    """
431    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
432        'gateway_amt', 'thirdparty_amt', 'p_item',
433        'p_split_data','p_combi')
434    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
435    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
Note: See TracBrowser for help on using the repository browser.