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

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

Adjust to base package.

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