source: main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py @ 15362

Last change on this file since 15362 was 15352, checked in by Henrik Bettermann, 6 years ago

Add ExportJHLIdCard page.

Make email field required on CustomStudentBaseEditFormPage?.

  • Property svn:keywords set to Id
File size: 25.3 KB
Line 
1## $Id: browser.py 15352 2019-03-13 17:48:36Z 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.security import checkPermission
21from zope.schema.interfaces import ConstraintNotSatisfied
22from zope.formlib.textwidgets import BytesDisplayWidget
23from zope.component import getUtility
24from hurry.workflow.interfaces import IWorkflowInfo
25from waeup.kofa.interfaces import (
26    REQUESTED, IExtFileStore, IKofaUtils, IObjectHistory)
27from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
28from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView
29from waeup.kofa.students.browser import (
30    StudentBaseEditFormPage,
31    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
32    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
33    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
34    msave, emit_lock_message,
35    StudentActivateView, StudentDeactivateView,
36    ExportPDFTranscriptSlip,
37    PaymentsManageFormPage)
38from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID,
39    CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED,
40    GRADUATED, FORBIDDEN_POSTGRAD_TRANS)
41from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
42from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
43from kofacustom.nigeria.students.browser import (
44    NigeriaOnlinePaymentDisplayFormPage,
45    NigeriaStudentBaseManageFormPage,
46    NigeriaStudentClearanceEditFormPage,
47    NigeriaOnlinePaymentAddFormPage,
48    NigeriaExportPDFPaymentSlip,
49    NigeriaExportPDFClearanceSlip,
50    NigeriaExportPDFBedTicketSlip,
51    NigeriaStudentPersonalDisplayFormPage,
52    NigeriaStudentPersonalManageFormPage,
53    NigeriaStudentPersonalEditFormPage,
54    NigeriaAccommodationManageFormPage
55    )
56
57from waeup.uniben.students.interfaces import (
58    ICustomStudent,
59    ICustomStudentBase,
60    ICustomStudentOnlinePayment,
61    ICustomStudentStudyCourse,
62    ICustomStudentStudyLevel,
63    ICustomUGStudentClearance,
64    ICustomPGStudentClearance,
65    ICustomStudentPersonal,
66    ICustomStudentPersonalEdit)
67from waeup.uniben.interfaces import MessageFactory as _
68
69class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
70    """ Page to view an online payment ticket
71    """
72    grok.context(ICustomStudentOnlinePayment)
73    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
74        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
75    form_fields[
76        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
77    form_fields[
78        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
79
80class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
81    """ View to edit student clearance data by student
82    """
83
84    @property
85    def form_fields(self):
86        if self.context.is_postgrad:
87            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit(
88            'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment',
89            'physical_clearance_date')
90        else:
91            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit(
92            'clearance_locked', 'clr_code', 'officer_comment',
93            'physical_clearance_date')
94            form_fields['date_of_birth'].for_display = True
95            form_fields['nationality'].for_display = True
96            form_fields['lga'].for_display = True
97        return form_fields
98
99    def dataNotComplete(self):
100        store = getUtility(IExtFileStore)
101        if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'):
102            return _('No birth certificate uploaded.')
103        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
104            return _('No guarantor/referee letter uploaded.')
105        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
106            return _('No acceptance letter uploaded.')
107        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
108            return _('No first sitting result uploaded.')
109        #if not store.getFileByContext(self.context, attr=u'scd_sit_scan.jpg'):
110        #    return _('No second sitting result uploaded.')
111        if not store.getFileByContext(self.context, attr=u'secr_cults.jpg'):
112            return _('No affidavit of non-membership of secret cults uploaded.')
113        return False
114
115class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
116    """ Page to add an online payment ticket
117    """
118    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
119        'p_category')
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')
127    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
128    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
129
130
131class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
132    """Deliver a PDF slip of the context.
133    """
134
135    @property
136    def omit_fields(self):
137        omit_fields = ('password', 'suspended', 'suspended_comment',
138                       'phone', 'adm_code', 'email', 'date_of_birth',
139                       'flash_notice')
140        if self.context.is_jupeb:
141            omit_fields += ('faculty', 'department')
142        return omit_fields
143
144    @property
145    def label(self):
146        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
147        line0 = ''
148        if self.context.is_jupeb:
149            line0 = 'Joint Universities Preliminary Examinations Board (JUPEB)\n'
150        line1 = translate(_('Clearance Slip of'),
151            'waeup.kofa', target_language=portal_language) \
152            + ' %s' % self.context.display_fullname
153        return '%s%s' % (line0, line1)
154
155    def _sigsInFooter(self):
156        isStudent = getattr(
157            self.request.principal, 'user_type', None) == 'student'
158        if not isStudent and self.context.state in (CLEARED, RETURNING):
159            return (_('Date, Student Signature'),
160                    _('Date, Clearance Officer Signature'),
161                    )
162        return ()
163
164    def render(self):
165        studentview = StudentBasePDFFormPage(self.context.student,
166            self.request, self.omit_fields)
167        students_utils = getUtility(IStudentsUtils)
168        return students_utils.renderPDF(
169            self, 'clearance_slip.pdf',
170            self.context.student, studentview, signatures=self._signatures(),
171            sigs_in_footer=self._sigsInFooter(), show_scans=False,
172            omit_fields=self.omit_fields)
173
174
175class ExportClearanceInvitationSlip(UtilityView, grok.View):
176    """Deliver an invitation letter to physical clearance.
177
178    This form page is available only in Uniben.
179    """
180    grok.context(ICustomStudent)
181    grok.name('clearance_invitation_slip.pdf')
182    grok.require('waeup.viewStudent')
183    prefix = 'form'
184
185    label = u'Invitation Letter for Physical Clearance'
186
187    omit_fields = (
188        'suspended', 'phone', 'email',
189        'adm_code', 'suspended_comment',
190        'date_of_birth', 'current_level',
191        'department', 'current_mode',
192        'entry_session', 'matric_number', 'sex',
193        'flash_notice')
194
195    form_fields = []
196
197    @property
198    def note(self):
199        if self.context.physical_clearance_date:
200            return """
201<br /><br /><br /><br /><font size='12'>
202Dear %s,
203<br /><br /><br />
204You are invited for your physical clearance on:
205<br /><br />
206<strong>%s</strong>.
207<br /><br />
208Please bring along this letter of invitation to the University Main Auditorium
209<br /><br />
210on your clearance date.
211<br /><br /><br />
212Signed,
213<br /><br />
214The Registrar<br />
215</font>
216
217""" % (self.context.display_fullname, self.context.physical_clearance_date)
218        return
219
220
221    def update(self):
222        if self.context.student.state != REQUESTED \
223            or not  self.context.student.physical_clearance_date:
224            self.flash(_('Forbidden'), type="warning")
225            self.redirect(self.url(self.context))
226
227    def render(self):
228        studentview = StudentBasePDFFormPage(self.context.student,
229            self.request, self.omit_fields)
230        students_utils = getUtility(IStudentsUtils)
231        return students_utils.renderPDF(
232            self, 'clearance_invitation_slip',
233            self.context.student, studentview,
234            omit_fields=self.omit_fields,
235            note=self.note)
236
237class ExportExaminationScheduleSlip(UtilityView, grok.View):
238    """Deliver a examination schedule slip.
239
240    This form page is available only in Uniben and AAUE.
241    """
242    grok.context(ICustomStudent)
243    grok.name('examination_schedule_slip.pdf')
244    grok.require('waeup.viewStudent')
245    prefix = 'form'
246
247    label = u'Examination Schedule Slip'
248
249    omit_fields = (
250        'suspended', 'phone', 'email',
251        'adm_code', 'suspended_comment',
252        'date_of_birth', 'current_level',
253        'current_mode',
254        'entry_session',
255        'flash_notice')
256
257    form_fields = []
258
259    @property
260    def note(self):
261        return """
262<br /><br /><br /><br /><font size='12'>
263Your examination date, time and venue is scheduled as follows:
264<br /><br />
265<strong>%s</strong>
266</font>
267
268""" % self.context.flash_notice
269        return
270
271
272    def update(self):
273        if not self.context.flash_notice \
274            or not 'exam' in self.context.flash_notice.lower():
275            self.flash(_('Forbidden'), type="warning")
276            self.redirect(self.url(self.context))
277
278    def render(self):
279        studentview = StudentBasePDFFormPage(self.context.student,
280            self.request, self.omit_fields)
281        students_utils = getUtility(IStudentsUtils)
282        return students_utils.renderPDF(
283            self, 'examination_schedule_slip',
284            self.context.student, studentview,
285            omit_fields=self.omit_fields,
286            note=self.note)
287
288class ExportJHLIdCard(UtilityView, grok.View):
289    """Deliver a an id card for the John Harris Library.
290    """
291    grok.context(ICustomStudent)
292    grok.name('jhl_idcard.pdf')
293    grok.require('waeup.viewStudent')
294    prefix = 'form'
295
296    label = u"John Harris Library Reader's Ticket"
297
298    omit_fields = (
299        'suspended', 'email',
300        'adm_code', 'suspended_comment',
301        'date_of_birth','reg_number',
302        'current_mode', 'certificate',
303        'entry_session',
304        'flash_notice')
305
306    form_fields = []
307
308    def _signatures(self):
309        return ([(
310            'Current HD<br /> D. R. (Exams & Records)<br /> '
311            'For: Registrar')],)
312
313    def _sigsInFooter(self):
314        return (_("Date, Reader's Signature"),
315                _("Date, Circulation Librarian's Signature"),
316                )
317
318    @property
319    def note(self):
320        return """
321<br /><br /><br /><br /><font size='12'>
322This is to certify that the bearer whose photograph and other details appear
323 overleaf is a registered user of <b>John Harris Library, University of Benin</b>.
324 The card is not transferable. A replacement fee is charged for a loss,
325 mutilation or otherwise. If found, please, return to John Harris Library,
326 University of Benin, Benin City.
327</font>
328
329"""
330        return
331
332    def render(self):
333        studentview = StudentBasePDFFormPage(self.context.student,
334            self.request, self.omit_fields)
335        students_utils = getUtility(IStudentsUtils)
336        return students_utils.renderPDF(
337            self, 'jhl_idcard',
338            self.context.student, studentview,
339            omit_fields=self.omit_fields,
340            sigs_in_footer=self._sigsInFooter(),
341            note=self.note)
342
343class ExportJUPEBResultSlip(ExportExaminationScheduleSlip):
344    """Deliver a JUPEB result slip.
345
346    This form page is available only in Uniben.
347    """
348
349    grok.name('jupeb_result_slip.pdf')
350    label = u'JUPEB Result Slip'
351
352    @property
353    def note(self):
354        return """
355<br /><br /><br /><br /><font size='12'>
356<strong>%s</strong>
357</font>
358<br /><br /><br /><br />
359<font size='8'>
360Key: A = 5, B = 4, C = 3, D = 2, E = 1, F = 0, X = Absent, Q = Cancelled
361</font>
362
363""" % self.context.flash_notice
364        return
365
366    def update(self):
367        if not self.context.flash_notice or not self.context.is_jupeb \
368            or not 'results' in self.context.flash_notice.lower():
369            self.flash(_('Forbidden'), type="warning")
370            self.redirect(self.url(self.context))
371
372class CustomStudentPersonalDisplayFormPage(
373    NigeriaStudentPersonalDisplayFormPage):
374    """ Page to display student personal data
375    """
376
377    form_fields = grok.AutoFields(ICustomStudentPersonal)
378    form_fields['perm_address'].custom_widget = BytesDisplayWidget
379    form_fields['next_kin_address'].custom_widget = BytesDisplayWidget
380    form_fields[
381        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
382
383class CustomStudentPersonalManageFormPage(
384    NigeriaStudentPersonalManageFormPage):
385    """ Page to manage personal data
386    """
387
388    form_fields = grok.AutoFields(ICustomStudentPersonal)
389    form_fields['personal_updated'].for_display = True
390    form_fields[
391        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
392
393class CstomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
394    """ Page to edit personal data
395    """
396    form_fields = grok.AutoFields(
397        ICustomStudentPersonalEdit).omit('personal_updated')
398
399class StudyCourseCOEditFormPage(KofaEditFormPage):
400    """ Page to edit the student study course data by clearance officers.
401
402    This form page is available only in Uniben.
403    """
404    grok.context(ICustomStudentStudyCourse)
405    grok.name('edit_level')
406    grok.require('waeup.clearStudent')
407    label = _('Edit current level')
408    pnav = 4
409    form_fields = grok.AutoFields(
410        ICustomStudentStudyCourse).select('current_level')
411
412    def update(self):
413        if not (self.context.is_current and
414            self.context.student.state == REQUESTED):
415            emit_lock_message(self)
416            return
417        super(StudyCourseCOEditFormPage, self).update()
418        return
419
420    @action(_('Save'), style='primary')
421    def save(self, **data):
422        try:
423            msave(self, **data)
424        except ConstraintNotSatisfied:
425            # The selected level might not exist in certificate
426            self.flash(_('Current level not available for certificate.'))
427            return
428        #notify(grok.ObjectModifiedEvent(self.context.__parent__))
429        return
430
431class CustomStudyLevelEditFormPage(StudyLevelEditFormPage):
432    """ Page to edit the student study level data by students.
433
434    """
435    grok.template('studyleveleditpage')
436
437class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
438    """ Page to display student study levels
439    """
440    grok.template('studylevelpage')
441
442class CustomExportPDFCourseRegistrationSlip(
443    ExportPDFCourseRegistrationSlip):
444    """Deliver a PDF slip of the context.
445    """
446
447    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
448        'level_verdict', 'gpa', 'level')
449
450    def update(self):
451        if self.context.student.state != REGISTERED \
452            or self.context.student.current_level != self.context.level:
453            self.flash(_('Forbidden'), type="warning")
454            self.redirect(self.url(self.context))
455
456    @property
457    def tabletitle(self):
458        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
459        tabletitle = []
460        tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa',
461            target_language=portal_language))
462        tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa',
463            target_language=portal_language))
464        tabletitle.append(translate(_('Level Courses'), 'waeup.kofa',
465            target_language=portal_language))
466        tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa',
467            target_language=portal_language))
468        tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa',
469            target_language=portal_language))
470        tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa',
471            target_language=portal_language))
472        return tabletitle
473
474    def render(self):
475        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
476        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
477        Title = translate('Title', 'waeup.kofa', target_language=portal_language)
478        Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language)
479        Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language)
480        Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language)
481        studentview = StudentBasePDFFormPage(self.context.student,
482            self.request, self.omit_fields)
483        students_utils = getUtility(IStudentsUtils)
484
485        tabledata = []
486        tableheader = []
487        for i in range(1,7):
488            tabledata.append(sorted(
489                [value for value in self.context.values() if value.semester == i],
490                key=lambda value: str(value.semester) + value.code))
491            tableheader.append([(Code,'code', 2.5),
492                             (Title,'title', 5),
493                             (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
494                             (Cred, 'credits', 1.5),
495                             ])
496        return students_utils.renderPDF(
497            self, 'course_registration_slip.pdf',
498            self.context.student, studentview,
499            tableheader=tableheader,
500            tabledata=tabledata,
501            omit_fields=self.omit_fields
502            )
503
504class UnibenExportPDFCourseResultSlip(ExportPDFCourseRegistrationSlip):
505    """Deliver a PDF slip of the context.
506    """
507
508    grok.name('course_result_slip.pdf')
509
510    @property
511    def tabletitle(self):
512        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
513        tabletitle = []
514        tabletitle.append(translate(_('1st Semester Courses'), 'waeup.kofa',
515            target_language=portal_language))
516        tabletitle.append(translate(_('2nd Semester Courses'), 'waeup.kofa',
517            target_language=portal_language))
518        tabletitle.append(translate(_('Level Courses'), 'waeup.kofa',
519            target_language=portal_language))
520        tabletitle.append(translate(_('1st Trimester Courses'), 'waeup.kofa',
521            target_language=portal_language))
522        tabletitle.append(translate(_('2nd Trimester Courses'), 'waeup.kofa',
523            target_language=portal_language))
524        tabletitle.append(translate(_('3rd Trimester Courses'), 'waeup.kofa',
525            target_language=portal_language))
526        return tabletitle
527
528    @property
529    def label(self):
530        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
531        lang = self.request.cookies.get('kofa.language', portal_language)
532        level_title = translate(self.context.level_title, 'waeup.kofa',
533            target_language=lang)
534        return translate(_('Course Result Slip'),
535            'waeup.uniben', target_language=portal_language) \
536            + ' %s' % level_title
537
538    def render(self):
539        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
540        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
541        Title = translate('Title', 'waeup.kofa', target_language=portal_language)
542        Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language)
543        Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language)
544        Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language)
545        Grade = translate('Grade', 'waeup.kofa', target_language=portal_language)
546        studentview = StudentBasePDFFormPage(self.context.student,
547            self.request, self.omit_fields)
548        students_utils = getUtility(IStudentsUtils)
549
550        tabledata = []
551        tableheader = []
552        for i in range(1,7):
553            tabledata.append(sorted(
554                [value for value in self.context.values() if value.semester == i],
555                key=lambda value: str(value.semester) + value.code))
556            tableheader.append([(Code,'code', 2.5),
557                             (Title,'title', 5),
558                             (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
559                             (Cred, 'credits', 1.5),
560                             (Grade, 'grade', 1.5),
561                             ])
562        return students_utils.renderPDF(
563            self, 'course_registration_slip.pdf',
564            self.context.student, studentview,
565            tableheader=tableheader,
566            tabledata=tabledata,
567            omit_fields=self.omit_fields
568            )
569
570class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
571    """ Page to display course tickets
572    """
573    form_fields = grok.AutoFields(ICourseTicket).omit('score')
574
575class CustomStudentActivateView(StudentActivateView):
576    """ Activate student account
577    """
578
579    def update(self):
580        self.context.suspended = False
581        self.context.writeLogMessage(self, 'account activated')
582        history = IObjectHistory(self.context)
583        history.addMessage('Student account activated', user='undisclosed')
584        self.flash(_('Student account has been activated.'))
585        self.redirect(self.url(self.context))
586        return
587
588class CustomStudentDeactivateView(StudentDeactivateView):
589    """ Deactivate student account
590    """
591    def update(self):
592        self.context.suspended = True
593        self.context.writeLogMessage(self, 'account deactivated')
594        history = IObjectHistory(self.context)
595        history.addMessage('Student account deactivated', user='undisclosed')
596        self.flash(_('Student account has been deactivated.'))
597        self.redirect(self.url(self.context))
598        return
599
600class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip):
601    """Deliver a PDF slip of the context.
602    """
603
604    #def _sigsInFooter(self):
605    #    isStudent = getattr(
606    #        self.request.principal, 'user_type', None) == 'student'
607    #    if not isStudent:
608    #        return (_('D. R. (Exams & Records)'),_('Current Dean of Faculty'),)
609    #    return ()
610
611    #def _signatures(self):
612    #    return ([(
613    #        'Current HD<br /> D. R. (Exams & Records)<br /> '
614    #        'For: Registrar')],)
615
616    def render(self):
617        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
618        Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language)
619        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
620        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
621        Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language)
622        #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
623        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
624        studentview = StudentBasePDFFormPage(self.context.student,
625            self.request, self.omit_fields)
626        students_utils = getUtility(IStudentsUtils)
627
628        tableheader = [(Code,'code', 2.5),
629                         (Title,'title', 8.5),
630                         (Term, 'semester', 1.5),
631                         (Cred, 'credits', 1.5),
632                         #(Score, 'score', 1.5),
633                         (Grade, 'grade', 1.5),
634                         ]
635
636        pdfstream = students_utils.renderPDFTranscript(
637            self, 'transcript.pdf',
638            self.context.student, studentview,
639            omit_fields=self.omit_fields,
640            tableheader=tableheader,
641            signatures=self._signatures(),
642            sigs_in_footer=self._sigsInFooter(),
643            digital_sigs=self._digital_sigs(),
644            save_file=self._save_file(),
645            )
646        if not pdfstream:
647            self.redirect(self.url(self.context.student))
648            return
649        return pdfstream
650
651class CustomExportPDFBedTicketSlip(NigeriaExportPDFBedTicketSlip):
652    """Deliver a PDF slip of the context.
653    """
654    omit_fields = ('password', 'suspended', 'suspended_comment',
655        'phone', 'adm_code', 'email', 'date_of_birth', 'flash_notice')
656
657class CustomPaymentsManageFormPage(PaymentsManageFormPage):
658    """ Page to manage the student payments. This manage form page is for
659    both students and students officers. Uniben does not allow students
660    to remove any payment ticket.
661    """
662    @property
663    def manage_payments_allowed(self):
664        return checkPermission('waeup.manageStudent', self.context)
665
666class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
667    """ Page to manage bed tickets.
668    This manage form page is for both students and students officers.
669    """
670    with_hostel_selection = True
671
672class CustomStudentBaseEditFormPage(StudentBaseEditFormPage):
673    """ View to edit student base data
674    """
675    form_fields = grok.AutoFields(ICustomStudentBase).select(
676        'email', 'phone')
677    form_fields['email'].field.required = True
Note: See TracBrowser for help on using the repository browser.