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

Last change on this file since 15957 was 15940, checked in by Henrik Bettermann, 5 years ago

Change permissions for payment approval.

  • Property svn:keywords set to Id
File size: 8.2 KB
RevLine 
[8911]1## $Id: browser.py 15940 2020-01-20 12:10:15Z 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
[9945]24from waeup.kofa.interfaces import ADMITTED, 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,
32    OnlinePaymentApproveView)
[8911]33from kofacustom.nigeria.students.browser import (
34    NigeriaOnlinePaymentDisplayFormPage,
35    NigeriaOnlinePaymentAddFormPage,
[13060]36    NigeriaExportPDFPaymentSlip,
[9190]37    NigeriaStudentClearanceEditFormPage,
[14591]38    NigeriaExportPDFClearanceSlip,
[15717]39    NigeriaExportPDFCourseRegistrationSlip,
40    NigeriaBedTicketAddPage,
[9190]41    )
[8911]42
[10019]43from waeup.fceokene.students.interfaces import (
[14591]44    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
45    ICustomStudentStudyLevel)
[8911]46
[13060]47class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
[9945]48    """Deliver a PDF Admission slip.
49    """
50
51    @property
52    def label(self):
53        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
54        line0 = ''
55        if self.context.student.current_mode.startswith('ug'):
56            line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n'
57        line1 = translate(_('Admission Letter of'),
58            'waeup.kofa', target_language=portal_language) \
59            + ' %s' % self.context.display_fullname
60        return '%s%s' % (line0, line1)
61
[15507]62    @property
63    def _post_text(self):
64        return """You should note the following as conditions for admission:
65
[15887]661. At the point of registration, you will be required to present the originals of your certificate(s),
67   Jamb Original Result, a Birth Certificate or a Declaration of Age Certificate and Evidence of
68   Citizenship Certificate.
[15690]69
[15887]702. Please note that the name by which you are hereby admitted and by which you will be registered
71   is the one which will appear on any certificate that the Federal College of Education, Okene may
72   issue to you on successful completion of your programme except there was a change of name by
73   sworn affidavit or marriage certificate in addition to newspaper publication.
[15690]74
[15887]753. You are hereby informed that all fees must be paid at the beginning of the academic session.
76   The current school fees can be obtained from the College website.
[15690]77
[15887]784. You will present at the time of registration the Medical Certificate of Fitness from the Federal
79   College of Education, Okene Medical Centre.
[15690]80
[15887]815. Please, note that due to shortage of accommodations, students shall be given accommodations
82   on first come, first serve basis.
[15690]83
[15509]846. The offer is not transferable to another session.
[15507]85
[15887]867. You will sign a declaration of good conduct except by deferment on your arrival at the College.
[15690]87
[15507]88Accept my congratulations.
89
90Yours faithfully
91
92M. S. Adoke
93Deputy Registrar (Admissions)
94For: Registrar
95"""
96
97    def render(self):
98        students_utils = getUtility(IStudentsUtils)
[15887]99        letterhead_path = os.path.join(
100            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
[15894]101        topMargin=1.6
[15887]102        if self.context.student.current_mode.startswith('ug'):
103            letterhead_path = None
[15890]104            topMargin=1.5
[15507]105        return students_utils.renderPDFAdmissionLetter(self,
106            self.context.student, omit_fields=self.omit_fields,
[15887]107            letterhead_path=letterhead_path,
[15890]108            topMargin=topMargin,
[15507]109            post_text=self._post_text)
110
[8911]111class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
112    """ Page to view an online payment ticket
113    """
114    grok.context(ICustomStudentOnlinePayment)
[9780]115    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]116        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]117    form_fields[
118        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
119    form_fields[
120        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
121
122class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
123    """ Page to add an online payment ticket
124    """
125    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
[15668]126        'p_combi')
[8911]127
[15940]128class OnlinePaymentApproveView(OnlinePaymentApproveView):
129    grok.require('waeup.manageStudent')
130
[13060]131class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
[8911]132    """Deliver a PDF slip of the context.
133    """
134    grok.context(ICustomStudentOnlinePayment)
[9780]135    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[15690]136        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
[8911]137    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9156]138    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
139
[10529]140    note = '''
141
142
143The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
144'''
145
[9156]146class CustomStartClearancePage(StartClearancePage):
147
[9953]148    @property
149    def with_ac(self):
150        mode = getattr(self.context, 'current_mode', None)
151        if mode and mode.startswith('ug'):
152            return True
153        return False
[9156]154
[13060]155class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
[10019]156    """Deliver a PDF slip of the context.
157    """
158
159    @property
160    def form_fields(self):
161        if self.context.is_postgrad:
162            form_fields = grok.AutoFields(
163                ICustomPGStudentClearance).omit('clearance_locked')
164        else:
165            form_fields = grok.AutoFields(
166                ICustomUGStudentClearance).omit('clearance_locked')
167        if not getattr(self.context, 'officer_comment'):
168            form_fields = form_fields.omit('officer_comment')
169        return form_fields
170
171    @property
172    def label(self):
173        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
174
175        line0 = ''
176        if self.context.student.current_mode.startswith('ug'):
177            line0 = 'Directorate of Undergraduate Programme\n'
178        line1 = translate(_('Clearance Slip of'),
179            'waeup.kofa', target_language=portal_language) \
180            + ' %s' % self.context.display_fullname
181        return '%s%s' % (line0, line1)
182
183
[9181]184class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
185    """ View to edit student clearance data by student
186    """
187
188    def dataNotComplete(self):
[9190]189        return False
190
[15717]191class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
[9190]192    """ Page to add an online payment ticket
193    """
194    buttonname = _('Create bed ticket')
195    notice = ''
[14591]196    with_ac = False
197
198class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
199    """ Page to display student study levels
200    """
201    grok.context(ICustomStudentStudyLevel)
202    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
203    form_fields[
204        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
205
206class CustomExportPDFCourseRegistrationSlip(
207    NigeriaExportPDFCourseRegistrationSlip):
208    """Deliver a PDF slip of the context.
209    """
210    grok.context(ICustomStudentStudyLevel)
[15304]211    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
212
213class CustomPaymentsManageFormPage(PaymentsManageFormPage):
214    """ Page to manage the student payments. This manage form page is for
215    both students and students officers. FCEOkene does not allow students
216    to remove any payment ticket.
217    """
218    @property
219    def manage_payments_allowed(self):
220        return checkPermission('waeup.manageStudent', self.context)
Note: See TracBrowser for help on using the repository browser.