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

Last change on this file since 16965 was 16911, checked in by Henrik Bettermann, 3 years ago

Change name.

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