source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/browser.py @ 17734

Last change on this file since 17734 was 17577, checked in by Henrik Bettermann, 14 months ago

Shorten text.

  • Property svn:keywords set to Id
File size: 10.9 KB
RevLine 
[8911]1## $Id: browser.py 17577 2023-09-13 05:25:21Z 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
[15887]19import os
[8911]20from zope.i18n import translate
[9945]21from zope.component import getUtility
[15304]22from zope.security import checkPermission
[9156]23from hurry.workflow.interfaces import IWorkflowInfo
[15977]24from waeup.kofa.interfaces import ADMITTED, VALIDATED, IKofaUtils
[9156]25from waeup.kofa.interfaces import MessageFactory as _
[8911]26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15507]27from waeup.kofa.students.interfaces import IStudentsUtils
[9945]28from waeup.kofa.students.browser import (
[15717]29    StartClearancePage,
[15304]30    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage,
[15940]31    PaymentsManageFormPage,
[15977]32    OnlinePaymentApproveView,
33    StudentBasePDFFormPage)
[8911]34from kofacustom.nigeria.students.browser import (
35    NigeriaOnlinePaymentDisplayFormPage,
36    NigeriaOnlinePaymentAddFormPage,
[13060]37    NigeriaExportPDFPaymentSlip,
[9190]38    NigeriaStudentClearanceEditFormPage,
[14591]39    NigeriaExportPDFClearanceSlip,
[15717]40    NigeriaExportPDFCourseRegistrationSlip,
41    NigeriaBedTicketAddPage,
[16366]42    NigeriaAccommodationManageFormPage,
43    NigeriaAccommodationDisplayFormPage,
[9190]44    )
[8911]45
[10019]46from waeup.fceokene.students.interfaces import (
[14591]47    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
48    ICustomStudentStudyLevel)
[8911]49
[13060]50class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
[9945]51    """Deliver a PDF Admission slip.
52    """
53
54    @property
55    def label(self):
56        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
57        line0 = ''
58        if self.context.student.current_mode.startswith('ug'):
59            line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n'
60        line1 = translate(_('Admission Letter of'),
61            'waeup.kofa', target_language=portal_language) \
62            + ' %s' % self.context.display_fullname
63        return '%s%s' % (line0, line1)
64
[15507]65    @property
66    def _post_text(self):
67        return """You should note the following as conditions for admission:
68
[17565]691. At the point of registration, you will be required to present the originals of your
70   certificate(s), Jamb Original Result, a Birth Certificate or a Declaration of
71   Age Certificate and Evidence of Citizenship Certificate.
[15690]72
[17565]732. Please note that the name by which you are hereby admitted and by which you will
74   be registered is the one which will appear on any certificate that the
75   Federal College of Education, Okene may issue to you on successful completion of
76   your programme except there was a change of name by sworn affidavit or
77   marriage certificate in addition to newspaper publication.
[15690]78
[17565]793. You are hereby informed that all fees must be paid at the beginning of the
80   academic session. The current school fees can be obtained from the College website.
[15690]81
[17565]824. You will present at the time of registration the Medical Certificate of Fitness
83   from the Federal College of Education, Okene Medical Centre.
[15690]84
[17577]855. Students shall be given accommodations on first come, first serve basis.
[15690]86
[15509]876. The offer is not transferable to another session.
[15507]88
[17565]897. You will sign a declaration of good conduct except by deferment on your
90   arrival at the College.
[15690]91
[17565]92Accept my congratulations. Yours faithfully
[15507]93
[17566]94Ajoge E, A
[15507]95Deputy Registrar (Admissions)
96For: Registrar
97"""
98
99    def render(self):
100        students_utils = getUtility(IStudentsUtils)
[15887]101        letterhead_path = os.path.join(
102            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
[15894]103        topMargin=1.6
[15887]104        if self.context.student.current_mode.startswith('ug'):
105            letterhead_path = None
[15890]106            topMargin=1.5
[15507]107        return students_utils.renderPDFAdmissionLetter(self,
108            self.context.student, omit_fields=self.omit_fields,
[15887]109            letterhead_path=letterhead_path,
[15890]110            topMargin=topMargin,
[15507]111            post_text=self._post_text)
112
[8911]113class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
114    """ Page to view an online payment ticket
115    """
116    grok.context(ICustomStudentOnlinePayment)
[9780]117    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]118        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]119    form_fields[
120        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
121    form_fields[
122        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
123
124class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
125    """ Page to add an online payment ticket
126    """
127    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
[15668]128        'p_combi')
[8911]129
[15940]130class OnlinePaymentApproveView(OnlinePaymentApproveView):
131    grok.require('waeup.manageStudent')
132
[13060]133class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
[8911]134    """Deliver a PDF slip of the context.
135    """
136    grok.context(ICustomStudentOnlinePayment)
[9780]137    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]138        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]139    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9156]140    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
141
142class CustomStartClearancePage(StartClearancePage):
143
[9953]144    @property
145    def with_ac(self):
146        mode = getattr(self.context, 'current_mode', None)
147        if mode and mode.startswith('ug'):
148            return True
149        return False
[9156]150
[13060]151class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
[10019]152    """Deliver a PDF slip of the context.
153    """
154
155    @property
156    def form_fields(self):
157        if self.context.is_postgrad:
158            form_fields = grok.AutoFields(
159                ICustomPGStudentClearance).omit('clearance_locked')
160        else:
161            form_fields = grok.AutoFields(
162                ICustomUGStudentClearance).omit('clearance_locked')
163        if not getattr(self.context, 'officer_comment'):
164            form_fields = form_fields.omit('officer_comment')
165        return form_fields
166
167    @property
168    def label(self):
169        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
170
171        line0 = ''
172        if self.context.student.current_mode.startswith('ug'):
173            line0 = 'Directorate of Undergraduate Programme\n'
174        line1 = translate(_('Clearance Slip of'),
175            'waeup.kofa', target_language=portal_language) \
176            + ' %s' % self.context.display_fullname
177        return '%s%s' % (line0, line1)
178
179
[9181]180class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
181    """ View to edit student clearance data by student
182    """
183
184    def dataNotComplete(self):
[9190]185        return False
186
[15717]187class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
[9190]188    """ Page to add an online payment ticket
189    """
190    buttonname = _('Create bed ticket')
191    notice = ''
[14591]192    with_ac = False
[16366]193    with_bedselection = True
[14591]194
195class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
196    """ Page to display student study levels
197    """
198    grok.context(ICustomStudentStudyLevel)
199    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
200    form_fields[
201        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
202
203class CustomExportPDFCourseRegistrationSlip(
204    NigeriaExportPDFCourseRegistrationSlip):
205    """Deliver a PDF slip of the context.
206    """
207    grok.context(ICustomStudentStudyLevel)
[15304]208    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
209
[15989]210class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip):
[15977]211    """Deliver a PDF slip of the context.
212    """
[15989]213    grok.name('examination_clearance_slip_1.pdf')
[15982]214    form_fields = None
215    omit_fields = (
216        'password', 'suspended', 'phone', 'date_of_birth',
217        'parents_email', 'current_mode', 'entry_session',
218        'adm_code', 'sex', 'suspended_comment',
219        'flash_notice')
[15989]220    semester = 1
221    tabletitle =  ['', '', '']
[15982]222
[15977]223    @property
224    def label(self):
[15989]225        return '%s First Semester Examination Clearance' % self.context.level_session
[15977]226
[15982]227    @property
228    def title(self):
229        return ''
230
[15977]231    def update(self):
232        if self.context.student.state != VALIDATED \
233            or self.context.student.current_level != self.context.level:
234            self.flash(_('Forbidden'), type="warning")
235            self.redirect(self.url(self.context))
236
237    def render(self):
238        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
239        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
240        studentview = StudentBasePDFFormPage(self.context.student,
241            self.request, self.omit_fields)
242        students_utils = getUtility(IStudentsUtils)
243
244        tabledata = []
245        tableheader = []
246        for i in range(1,7):
247            tabledata.append(sorted(
[15989]248                [value for value in self.context.values() if i == self.semester == value.semester],
249                key=lambda value: value.code))
[15977]250            tableheader.append([(Code,'code', 2.5),
[15989]251                             ('Invigilator\'s Name','inv', 8),
[15993]252                             ('Signature and Date','sig', 7),
[15977]253                             ])
254        return students_utils.renderPDF(
[15989]255            self, 'examination_clearance_slip_%s.pdf' % self.semester,
[15977]256            self.context.student, studentview,
257            tableheader=tableheader,
258            tabledata=tabledata,
[15983]259            omit_fields=self.omit_fields,
[15989]260            topMargin=1.3
[15977]261            )
262
[15989]263class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1):
264    """Deliver a PDF slip of the context.
265    """
266    grok.name('examination_clearance_slip_2.pdf')
267    semester = 2
[15977]268
[15989]269    @property
270    def label(self):
271        return '%s Second Semester Examination Clearance' % self.context.level_session
272
[15304]273class CustomPaymentsManageFormPage(PaymentsManageFormPage):
274    """ Page to manage the student payments. This manage form page is for
275    both students and students officers. FCEOkene does not allow students
276    to remove any payment ticket.
277    """
278    @property
279    def manage_payments_allowed(self):
[16366]280        return checkPermission('waeup.manageStudent', self.context)
281
282class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
283    """ Page to view bed tickets.
284    """
285    with_hostel_selection = True
286
287class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
288    """ Page to manage bed tickets.
289    This manage form page is for both students and students officers.
290    """
291    with_hostel_selection = True
Note: See TracBrowser for help on using the repository browser.