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

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

Use file merger.

  • Property svn:keywords set to Id
File size: 12.9 KB
Line 
1## $Id: browser.py 16160 2020-07-10 06:13:51Z 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 (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.
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
2671. Fees can be paid on through you portal page. Download the pdf document <link href='https://iuokada.waeup.org/documents/IUOAL/file.pdf'><strong>Fee Structure and Fees Payment Procedure</strong></link> for the options you have to make your payment, as well as instructions on how to use your preferred payment option.
2682. 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, and Keystone Bank.
269
270Kindly note the following:
271
2721. Fees indicated on the fee structure page are valid for the current session only.
2732. Your Student Id (indicated above) is your login to the university portal.
2743. As an indication of your acceptance of this offer of admission, you should pay a non-refundable acceptance deposit of N200,000. Further note that the N200,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.
2754. 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. Installmental payments of not more than two installments may be allowed under exceptional circumstances.
2765. Fees once paid are not refundable.
2776. It is advisable that you keep the original receipts of fees paid and present them on demand.
278
279Accommodation: 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. For further details, please refer to the bursary for information on fees.
280
281Food: Food is available in cafeteria on "pay-as-you-eat" basis.
282
283Resumption Date: The University opens for fresh students on Saturday, 28th September, 2020. All newly admitted students are expected to report on that date.
284
285Registration/Orientation Programme: Orientation programme/registration for fresh students will start on Monday, 30th September 2020. Registration ends on 30th October. 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 if it is found that any of your claims in the application form is false.
286
287Transport Facility: The university provides a compulsory shuttle bus service to all students at a fee already included in the other charges.
288
289Kindly note that fresh students are not allowed the use of private vehicles.
290
291Conduct: 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.
292
293We wish you a successful academic career In Igbinedion University.
294
295Congratulations!
296
297L.P.E. Jagbedia
298Ag. Registrar
299registrar@iuokada.edo.ng
30008037349527
301"""
302
303    def render(self):
304        students_utils = getUtility(IStudentsUtils)
305        watermark_path = os.path.join(
306            os.path.dirname(__file__), 'static', 'watermark.pdf')
307        watermark = open(watermark_path, 'rb')
308        file_path = os.path.join(
309            os.path.dirname(__file__), 'static', 'admission_letter.pdf')
310        file = open(file_path, 'rb')
311        mergefiles = [file,]
312        return students_utils.renderPDFAdmissionLetter(self,
313            self.context.student, omit_fields=self.omit_fields,
314            pre_text=self.pre_text, post_text=self.post_text,
315            mergefiles=mergefiles,
316            watermark=watermark)
Note: See TracBrowser for help on using the repository browser.