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

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

Reduce top_margin.

  • Property svn:keywords set to Id
File size: 8.1 KB
Line 
1## $Id: browser.py 15894 2019-12-18 10:06:48Z 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.component import getUtility
22from zope.security import checkPermission
23from hurry.workflow.interfaces import IWorkflowInfo
24from waeup.kofa.interfaces import ADMITTED, IKofaUtils
25from waeup.kofa.interfaces import MessageFactory as _
26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
27from waeup.kofa.students.interfaces import IStudentsUtils
28from waeup.kofa.students.browser import (
29    StartClearancePage,
30    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage,
31    PaymentsManageFormPage)
32from kofacustom.nigeria.students.browser import (
33    NigeriaOnlinePaymentDisplayFormPage,
34    NigeriaOnlinePaymentAddFormPage,
35    NigeriaExportPDFPaymentSlip,
36    NigeriaStudentClearanceEditFormPage,
37    NigeriaExportPDFClearanceSlip,
38    NigeriaExportPDFCourseRegistrationSlip,
39    NigeriaBedTicketAddPage,
40    )
41
42from waeup.fceokene.students.interfaces import (
43    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
44    ICustomStudentStudyLevel)
45
46class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
47    """Deliver a PDF Admission slip.
48    """
49
50    @property
51    def label(self):
52        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
53        line0 = ''
54        if self.context.student.current_mode.startswith('ug'):
55            line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n'
56        line1 = translate(_('Admission Letter of'),
57            'waeup.kofa', target_language=portal_language) \
58            + ' %s' % self.context.display_fullname
59        return '%s%s' % (line0, line1)
60
61    @property
62    def _post_text(self):
63        return """You should note the following as conditions for admission:
64
651. At the point of registration, you will be required to present the originals of your certificate(s),
66   Jamb Original Result, a Birth Certificate or a Declaration of Age Certificate and Evidence of
67   Citizenship Certificate.
68
692. Please note that the name by which you are hereby admitted and by which you will be registered
70   is the one which will appear on any certificate that the Federal College of Education, Okene may
71   issue to you on successful completion of your programme except there was a change of name by
72   sworn affidavit or marriage certificate in addition to newspaper publication.
73
743. You are hereby informed that all fees must be paid at the beginning of the academic session.
75   The current school fees can be obtained from the College website.
76
774. You will present at the time of registration the Medical Certificate of Fitness from the Federal
78   College of Education, Okene Medical Centre.
79
805. Please, note that due to shortage of accommodations, students shall be given accommodations
81   on first come, first serve basis.
82
836. The offer is not transferable to another session.
84
857. You will sign a declaration of good conduct except by deferment on your arrival at the College.
86
87Accept my congratulations.
88
89Yours faithfully
90
91M. S. Adoke
92Deputy Registrar (Admissions)
93For: Registrar
94"""
95
96    def render(self):
97        students_utils = getUtility(IStudentsUtils)
98        letterhead_path = os.path.join(
99            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
100        topMargin=1.6
101        if self.context.student.current_mode.startswith('ug'):
102            letterhead_path = None
103            topMargin=1.5
104        return students_utils.renderPDFAdmissionLetter(self,
105            self.context.student, omit_fields=self.omit_fields,
106            letterhead_path=letterhead_path,
107            topMargin=topMargin,
108            post_text=self._post_text)
109
110class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
111    """ Page to view an online payment ticket
112    """
113    grok.context(ICustomStudentOnlinePayment)
114    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
115        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
116    form_fields[
117        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
118    form_fields[
119        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
120
121class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
122    """ Page to add an online payment ticket
123    """
124    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
125        'p_combi')
126
127class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
128    """Deliver a PDF slip of the context.
129    """
130    grok.context(ICustomStudentOnlinePayment)
131    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
132        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
133    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
134    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
135
136    note = '''
137
138
139The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
140'''
141
142class CustomStartClearancePage(StartClearancePage):
143
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
150
151class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
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
180class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
181    """ View to edit student clearance data by student
182    """
183
184    def dataNotComplete(self):
185        return False
186
187class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
188    """ Page to add an online payment ticket
189    """
190    buttonname = _('Create bed ticket')
191    notice = ''
192    with_ac = False
193
194class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
195    """ Page to display student study levels
196    """
197    grok.context(ICustomStudentStudyLevel)
198    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
199    form_fields[
200        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
201
202class CustomExportPDFCourseRegistrationSlip(
203    NigeriaExportPDFCourseRegistrationSlip):
204    """Deliver a PDF slip of the context.
205    """
206    grok.context(ICustomStudentStudyLevel)
207    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
208
209class CustomPaymentsManageFormPage(PaymentsManageFormPage):
210    """ Page to manage the student payments. This manage form page is for
211    both students and students officers. FCEOkene does not allow students
212    to remove any payment ticket.
213    """
214    @property
215    def manage_payments_allowed(self):
216        return checkPermission('waeup.manageStudent', self.context)
Note: See TracBrowser for help on using the repository browser.