source: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py @ 10757

Last change on this file since 10757 was 10711, checked in by Henrik Bettermann, 11 years ago

Change notice.

  • Property svn:keywords set to Id
File size: 13.4 KB
Line 
1## $Id: browser.py 10711 2013-11-07 06:26:45Z 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.formlib.textwidgets import BytesDisplayWidget
21from zope.component import getUtility
22from hurry.workflow.interfaces import IWorkflowInfo
23from waeup.kofa.interfaces import ADMITTED, IKofaUtils
24from waeup.kofa.browser.layout import UtilityView
25from waeup.kofa.students.interfaces import IStudentsUtils
26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
27from waeup.kofa.students.browser import (
28    StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage,
29    StudentBasePDFFormPage)
30from waeup.kwarapoly.students.interfaces import (
31    ICustomStudent, ICustomStudentBase, ICustomStudentStudyLevel)
32from waeup.kwarapoly.interfaces import MessageFactory as _
33from waeup.kofa.students.workflow import (
34    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
35    VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE)
36from kofacustom.nigeria.students.browser import (
37    NigeriaOnlinePaymentDisplayFormPage,
38    NigeriaOnlinePaymentAddFormPage,
39    NigeriaExportPDFPaymentSlipPage,
40    NigeriaStudentClearanceEditFormPage,
41    NigeriaExportPDFCourseRegistrationSlipPage,
42    NigeriaStudentPersonalDisplayFormPage,
43    NigeriaStudentPersonalEditFormPage,
44    NigeriaStudentPersonalManageFormPage
45    )
46
47from waeup.kwarapoly.students.interfaces import (
48    ICustomStudentOnlinePayment,
49    ICustomStudentPersonal,
50    ICustomStudentPersonalEdit
51    )
52
53class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
54    """ Page to display student personal data
55    """
56    form_fields = grok.AutoFields(ICustomStudentPersonal)
57    form_fields['perm_address'].custom_widget = BytesDisplayWidget
58    form_fields['next_kin_address'].custom_widget = BytesDisplayWidget
59    form_fields['corr_address'].custom_widget = BytesDisplayWidget
60    form_fields['sponsor_address'].custom_widget = BytesDisplayWidget
61    form_fields[
62        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
63
64class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
65    """ Page to edit personal data
66    """
67    form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit(
68        'personal_updated')
69
70class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
71    """ Page to edit personal data
72    """
73    form_fields = grok.AutoFields(ICustomStudentPersonal)
74    form_fields['personal_updated'].for_display = True
75    form_fields[
76        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
77
78class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
79    """ Page to view an online payment ticket
80    """
81    grok.context(ICustomStudentOnlinePayment)
82    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
83        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
84    form_fields[
85        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
86    form_fields[
87        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
88
89class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
90    """ Page to add an online payment ticket
91    """
92    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
93        'p_category')
94
95class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
96    """Deliver a PDF slip of the context.
97    """
98    grok.context(ICustomStudentOnlinePayment)
99    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
100        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
101    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
102    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
103
104class CustomStartClearancePage(StartClearancePage):
105
106    with_ac = False
107
108class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
109    """ View to edit student clearance data by student
110    """
111
112    def dataNotComplete(self):
113        return False
114
115class BedTicketAddPage(BedTicketAddPage):
116    """ Page to add an online payment ticket
117    """
118    buttonname = _('Create bed ticket')
119    notice = ''
120    with_ac = False
121
122class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage):
123    """Deliver a PDF Admission slip.
124    """
125    grok.context(ICustomStudent)
126
127    omit_fields = ('date_of_birth',)
128
129    form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number')
130
131    def render(self):
132        if self.context.state in (CREATED, ADMITTED,
133                                  CLEARANCE, REQUESTED, CLEARED):
134            self.flash('Not allowed.')
135            self.redirect(self.url(self.context))
136            return
137        students_utils = getUtility(IStudentsUtils)
138        return students_utils.renderPDFAdmissionLetter(self,
139            self.context.student, omit_fields=self.omit_fields)
140
141class ExportPDFAdmissionNotificationPage(UtilityView, grok.View):
142    """Deliver a PDF Admission nostification slip.
143    """
144    grok.context(ICustomStudent)
145    grok.name('admission_notification.pdf')
146    grok.require('waeup.viewStudent')
147    prefix = 'form'
148    label = 'Notification of Provisional Admission'
149
150    omit_fields = ('date_of_birth',)
151
152    form_fields = grok.AutoFields(ICustomStudent).select(
153        'student_id', 'reg_number', 'sex', 'lga')
154
155    def render(self):
156        if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
157            self.flash('Not allowed.')
158            self.redirect(self.url(self.context))
159            return
160        students_utils = getUtility(IStudentsUtils)
161        pre_text = ''
162        post_text = post_text_freshers
163        return students_utils.renderPDFAdmissionLetter(self,
164            self.context.student, omit_fields=self.omit_fields,
165            pre_text=pre_text, post_text=post_text)
166
167# copied from waeup.aaue
168class CustomExportPDFCourseRegistrationSlipPage(
169    NigeriaExportPDFCourseRegistrationSlipPage):
170    """Deliver a PDF slip of the context.
171    """
172    grok.context(ICustomStudentStudyLevel)
173    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
174        'level_session', 'level_verdict',
175        'validated_by', 'validation_date', 'gpa')
176
177    omit_fields = ('password', 'suspended', 'suspended_comment',
178        'phone', 'adm_code', 'sex', 'email', 'date_of_birth',
179        'department', 'current_mode')
180
181    @property
182    def title(self):
183        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
184        return translate(_('Credits Registered'), 'waeup.kofa',
185            target_language=portal_language)
186
187    def _signatures(self):
188        return (
189            [('I have selected the course on the advise of my Head of '
190             'Department. <br>', _('Student\'s Signature'), '<br>')],
191            [('This student has satisfied the department\'s requirements. '
192             'I recommend to approve the course registration. <br>',
193             _('Head of Department\'s Signature'), '<br>')],
194            [('' , _('Principal Assistant Registrar\'s Signature'), '<br>')],
195            [('', _('Director\'s Signature'))]
196            )
197
198    def render(self):
199        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
200        Sem = translate('Sem.', 'waeup.kofa', target_language=portal_language)
201        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
202        Title = translate('Title', 'waeup.kofa', target_language=portal_language)
203        Cred = translate('Cred.', 'waeup.kofa', target_language=portal_language)
204        Score = translate('Score', 'waeup.kofa', target_language=portal_language)
205        Grade = translate('Grade', 'waeup.kofa', target_language=portal_language)
206        Signature = translate(_('HOD\'s Signature'), 'waeup.kwarapoly',
207            target_language=portal_language)
208        studentview = StudentBasePDFFormPage(self.context.student,
209            self.request, self.omit_fields)
210        students_utils = getUtility(IStudentsUtils)
211
212        tabledata = []
213        tableheader = []
214        contenttitle = []
215        for i in range(1,7):
216            tabledata.append(sorted(
217                [value for value in self.context.values() if value.semester == i],
218                key=lambda value: str(value.semester) + value.code))
219            tableheader.append([(Code,'code', 2.0),
220                               (Title,'title', 7),
221                               (Cred, 'credits', 1.5),
222                               (Score, 'score', 1.4),
223                               (Grade, 'grade', 1.4),
224                               (Signature, 'dummy', 3),
225                               ])
226        if len(self.label.split('\n')) == 3:
227            topMargin = 1.9
228        elif len(self.label.split('\n')) == 2:
229            topMargin = 1.7
230        else:
231            topMargin = 1.5
232        return students_utils.renderPDF(
233            self, 'course_registration_slip.pdf',
234            self.context.student, studentview,
235            tableheader=tableheader,
236            tabledata=tabledata,
237            signatures=self._signatures(),
238            topMargin=topMargin,
239            omit_fields=self.omit_fields
240            )
241
242class ExportPDFRegistrationSlipPage(grok.View):
243    """Deliver a PDF slip of the context.
244    """
245    grok.context(ICustomStudent)
246    grok.name('registration_slip.pdf')
247    grok.require('waeup.viewStudent')
248    prefix = 'form'
249    omit_fields = (
250        'suspended', 'phone',
251        'adm_code', 'suspended_comment', 'email',
252        'current_mode', 'matric_number', 'date_of_birth')
253    title = 'Clearance and Personal Data'
254    label = 'Profile Registration Slip'
255
256    form_fields = grok.AutoFields(ICustomStudent).select(
257        'date_of_birth', 'lga', 'nationality',
258        'perm_address', 'corr_address',
259        'marit_stat', 'sponsor_name', 'sponsor_address',
260        )
261
262    def render(self):
263        studentview = StudentBasePDFFormPage(self.context.student,
264            self.request, self.omit_fields)
265        students_utils = getUtility(IStudentsUtils)
266        return students_utils.renderPDF(
267            self, 'registration_slip.pdf',
268            self.context.student, studentview, signatures=([_('Bursar')],),
269            omit_fields=self.omit_fields,
270            note=post_text_registration)
271
272post_text_registration = """<br /><br /><br /><br />
273<strong>IMPORTANTANT NOTICE</strong>
274<br /><br />
275This registration slip must be submitted before attendance of lectures. Note that:<br /><br />
2761. All fees due must be paid in full.<br /><br />
2772. All information required must be available on the Registration Form.<br /><br />
2783. The Signature of all appropriate Polytechnic Authority must be obtained.<br /><br />
2794. The endorsed Registration Form should be returned to the respective Institutes and Administrative Offices.<br /><br />
2805. No student may change his subject or course of study as shown in the signed Registration Form without clearance from Admissions Office and the Director of the appropriate Institute.
281"""
282
283post_text_freshers = """
284<strong>INSTRUCTIONS TO FRESHERS</strong>
285<br /><br />
286You are hereby offered a provisional admission for the 2013/2014 session subject to the conditions that:
287<br /><br />
2881. The information given in your Application Form is correct.<br /><br />
2892. The original of your Credentials are presented for scrutiny.<br /><br />
2903. If at any time the Credentials submitted are found to be false/fake or incorrect, your admission shall be withdrawn.<br /><br />
2914. The name by which you are admitted and registered shall remain same throughout the duration of your programme.<br /><br />
2925. You are to fill and submit the Undertaking Form at the point of registration failure which your admission will be forfeited.<br /><br />
2936. You will dress decently covering your nakedness at all times.<br /><br />
2947. Payment of school fees will be once and in full and should be by Interswitch to the designated Banks. Failure to pay fees by the mode mentioned above by the closing date means you have declined the offer and your place will be given to another eligible candidate immediately.<br /><br />
2958. You present a Certificate of medical fitness from the Polytechnic Clinic.<br /><br />
2969. All indigenes of Kwara State are required to present Certificate of Citizenship.<br /><br />
29710. The Polytechnic reserves the right to withdraw your admission at any stage, if you are found to be a cultist or an expelled individual from any tertiary institution.<br /><br />
29811. You are prepared to take up accommodation provided on the campuses by the authority.<br /><br />
29912. There will be no refund of school fees once paid.<br /><br />
30013. If you accept this offer with above stated conditions, please make a photocopy of this document and return it to the Admission Office immediately.<br /><br />
30114. You possess the entry requirement for the programme you are admitted into before making payment of school fees and registration.<br /><br />
302"""
Note: See TracBrowser for help on using the repository browser.