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

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

Do not display p_combi.

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