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

Last change on this file since 18251 was 18251, checked in by Henrik Bettermann, 8 months ago

Change ExportPDFExaminationClearanceSlip1.

  • Property svn:keywords set to Id
File size: 13.1 KB
Line 
1## $Id: browser.py 18251 2026-04-06 08:51:29Z 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    NigeriaStudentClearanceDisplayFormPage,
39    NigeriaStudentClearanceEditFormPage,
40    NigeriaStudentClearanceManageFormPage,
41    NigeriaExportPDFClearanceSlip,
42    NigeriaExportPDFCourseRegistrationSlip,
43    NigeriaBedTicketAddPage,
44    NigeriaAccommodationManageFormPage,
45    NigeriaAccommodationDisplayFormPage,
46    )
47
48from waeup.fceokene.students.interfaces import (
49    ICustomStudentOnlinePayment,
50    ICustomUGStudentClearance,
51    ICustomPGStudentClearance,
52    ICustomStudentStudyLevel)
53
54class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
55    """Deliver a PDF Admission slip.
56    """
57
58    @property
59    def label(self):
60        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
61        line0 = ''
62        if self.context.student.current_mode.startswith('ug') and self.context.student.faccode != 'SUP':
63            line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n'
64        line1 = translate(_('Admission Letter of'),
65            'waeup.kofa', target_language=portal_language) \
66            + ' %s' % self.context.display_fullname
67        return '%s%s' % (line0, line1)
68
69    @property
70    def _post_text(self):
71        return """You should note the following as conditions for admission:
72
731. At the point of registration, you will be required to present the originals of your
74   certificate(s), Jamb Original Result, a Birth Certificate or a Declaration of
75   Age Certificate and Evidence of Citizenship Certificate.
76
772. Please note that the name by which you are hereby admitted and by which you will
78   be registered is the one which will appear on any certificate that the
79   Federal College of Education, Okene may issue to you on successful completion of
80   your programme except there was a change of name by sworn affidavit or
81   marriage certificate in addition to newspaper publication.
82
833. You are hereby informed that all fees must be paid at the beginning of the
84   academic session. The current school fees can be obtained from the College website.
85
864. You will present at the time of registration the Medical Certificate of Fitness
87   from the Federal College of Education, Okene Medical Centre.
88
895. Students shall be given accommodations on first come, first serve basis.
90
916. The offer is not transferable to another session.
92
937. You will sign a declaration of good conduct except by deferment on your
94   arrival at the College.
95
96Accept my congratulations. Yours faithfully
97
98Ajoge E, A
99Deputy Registrar (Admissions)
100For: Registrar
101"""
102
103    def render(self):
104        students_utils = getUtility(IStudentsUtils)
105        letterhead_path = os.path.join(
106            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
107        topMargin=1.8
108        if self.context.student.current_mode.startswith('ug') and self.context.student.faccode != 'SUP':
109            letterhead_path = None
110            topMargin=1.3
111        return students_utils.renderPDFAdmissionLetter(self,
112            self.context.student, omit_fields=self.omit_fields,
113            letterhead_path=letterhead_path,
114            topMargin=topMargin,
115            post_text=self._post_text)
116
117class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
118    """ Page to view an online payment ticket
119    """
120    grok.context(ICustomStudentOnlinePayment)
121    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
122        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
123    form_fields[
124        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
125    form_fields[
126        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
127
128class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
129    """ Page to add an online payment ticket
130    """
131    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
132        'p_combi')
133
134class OnlinePaymentApproveView(OnlinePaymentApproveView):
135    grok.require('waeup.manageStudent')
136
137class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
138    """Deliver a PDF slip of the context.
139    """
140    grok.context(ICustomStudentOnlinePayment)
141    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
142        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', 'p_combi')
143    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
144    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
145
146class CustomStartClearancePage(StartClearancePage):
147
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
154
155class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage):
156    """ Page to display student clearance data
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        else:
170            form_fields['officer_comment'].custom_widget = BytesDisplayWidget
171        return form_fields
172
173
174class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage):
175    """ Page to edit student clearance data
176    """
177
178    @property
179    def form_fields(self):
180        if self.context.is_postgrad:
181            form_fields = grok.AutoFields(
182                ICustomPGStudentClearance).omit('clr_code')
183        else:
184            form_fields = grok.AutoFields(
185                ICustomUGStudentClearance).omit('clr_code')
186        return form_fields
187
188
189class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
190    """Deliver a PDF slip of the context.
191    """
192
193    @property
194    def form_fields(self):
195        if self.context.is_postgrad:
196            form_fields = grok.AutoFields(
197                ICustomPGStudentClearance).omit('clearance_locked')
198        else:
199            form_fields = grok.AutoFields(
200                ICustomUGStudentClearance).omit('clearance_locked')
201        if not getattr(self.context, 'officer_comment'):
202            form_fields = form_fields.omit('officer_comment')
203        return form_fields
204
205    @property
206    def label(self):
207        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
208
209        line0 = ''
210        if self.context.student.current_mode.startswith('ug'):
211            line0 = 'Directorate of Undergraduate Programme\n'
212        line1 = translate(_('Clearance Slip of'),
213            'waeup.kofa', target_language=portal_language) \
214            + ' %s' % self.context.display_fullname
215        return '%s%s' % (line0, line1)
216
217
218class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
219    """ View to edit student clearance data by student
220    """
221
222    def dataNotComplete(self):
223        return False
224
225    @property
226    def form_fields(self):
227        if self.context.is_postgrad:
228            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit(
229            'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment',
230            'physical_clearance_date')
231        else:
232            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit(
233            'clearance_locked', 'clr_code', 'officer_comment',
234            'physical_clearance_date')
235        return form_fields
236
237class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
238    """ Page to add an online payment ticket
239    """
240    buttonname = _('Create bed ticket')
241    notice = ''
242    with_ac = False
243    with_bedselection = True
244
245class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
246    """ Page to display student study levels
247    """
248    grok.context(ICustomStudentStudyLevel)
249    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
250    form_fields[
251        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
252
253class CustomExportPDFCourseRegistrationSlip(
254    NigeriaExportPDFCourseRegistrationSlip):
255    """Deliver a PDF slip of the context.
256    """
257    grok.context(ICustomStudentStudyLevel)
258    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
259        'level', 'level_verdict', 'validated_by', 'transcript_remark', 'gpa')
260    form_fields[
261        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
262    omit_fields = ('password', 'suspended', 'suspended_comment',
263        'phone', 'adm_code', 'sex', 'email', 'date_of_birth', 'current_level',
264        'flash_notice', 'parents_email', 'entry_session', 'password_updated')
265
266class ExportPDFExaminationClearanceSlip1(CustomExportPDFCourseRegistrationSlip):
267    """Deliver a PDF slip of the context.
268    """
269    grok.name('examination_clearance_slip_1.pdf')
270    form_fields = None
271    omit_fields = (
272        'password', 'suspended', 'phone', 'date_of_birth',
273        'parents_email', 'current_mode', 'entry_session',
274        'adm_code', 'sex', 'suspended_comment',
275        'flash_notice', 'password_updated', 'current_level')
276    semester = 1
277    tabletitle =  ['', '', '']
278
279    @property
280    def label(self):
281        return '%s First Semester Examination Clearance' % self.context.level_session
282
283    @property
284    def title(self):
285        return ''
286
287    def update(self):
288        if self.context.student.state != VALIDATED \
289            or self.context.student.current_level != self.context.level:
290            self.flash(_('Forbidden'), type="warning")
291            self.redirect(self.url(self.context))
292
293    def render(self):
294        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
295        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
296        studentview = StudentBasePDFFormPage(self.context.student,
297            self.request, self.omit_fields)
298        students_utils = getUtility(IStudentsUtils)
299
300        tabledata = []
301        tableheader = []
302        for i in range(1,7):
303            tabledata.append(sorted(
304                [value for value in self.context.values() if i == self.semester == value.semester],
305                key=lambda value: value.code))
306            tableheader.append([(Code,'code', 2.5),
307                             ('Invigilator\'s Name','inv', 8),
308                             ('Signature and Date','sig', 7),
309                             ])
310        return students_utils.renderPDF(
311            self, 'examination_clearance_slip_%s.pdf' % self.semester,
312            self.context.student, studentview,
313            tableheader=tableheader,
314            tabledata=tabledata,
315            omit_fields=self.omit_fields,
316            topMargin=1.3
317            )
318
319class ExportPDFExaminationClearanceSlip2(ExportPDFExaminationClearanceSlip1):
320    """Deliver a PDF slip of the context.
321    """
322    grok.name('examination_clearance_slip_2.pdf')
323    semester = 2
324
325    @property
326    def label(self):
327        return '%s Second Semester Examination Clearance' % self.context.level_session
328
329class CustomPaymentsManageFormPage(PaymentsManageFormPage):
330    """ Page to manage the student payments. This manage form page is for
331    both students and students officers. FCEOkene does not allow students
332    to remove any payment ticket.
333    """
334    @property
335    def manage_payments_allowed(self):
336        return checkPermission('waeup.manageStudent', self.context)
337
338class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
339    """ Page to view bed tickets.
340    """
341    with_hostel_selection = True
342
343class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
344    """ Page to manage bed tickets.
345    This manage form page is for both students and students officers.
346    """
347    with_hostel_selection = True
Note: See TracBrowser for help on using the repository browser.