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

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

Remove transcript remark from course registration slip.

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