## $Id: browser.py 15294 2019-01-10 15:58:13Z henrik $
##
## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
import grok
from zope.i18n import translate
from zope.schema.interfaces import ConstraintNotSatisfied
from zope.component import getUtility
from hurry.workflow.interfaces import IWorkflowInfo
from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
from waeup.kofa.browser.layout import KofaEditFormPage
from waeup.kofa.browser.layout import action, jsaction
from waeup.kofa.students.browser import (
StudyLevelEditFormPage, StudyLevelDisplayFormPage,
StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
msave, emit_lock_message)
from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
from kofacustom.nigeria.students.browser import (
NigeriaOnlinePaymentDisplayFormPage,
NigeriaStudentBaseManageFormPage,
NigeriaStudentClearanceEditFormPage,
NigeriaOnlinePaymentAddFormPage,
NigeriaExportPDFPaymentSlip,
NigeriaExportPDFClearanceSlip,
NigeriaExportPDFCourseRegistrationSlip
)
from kofacustom.coewarri.students.interfaces import (
ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
ICustomStudentStudyLevel)
from kofacustom.coewarri.interfaces import MessageFactory as _
class CustomExportPDFCourseRegistrationSlip(
NigeriaExportPDFCourseRegistrationSlip):
"""Deliver a PDF slip of the context.
"""
grok.context(ICustomStudentStudyLevel)
def _signatures(self):
return (
[('I, ' + self.context.student.display_fullname +
', do hereby declare that the above information is '
'true and correct.
', _('Student\'s Signature'), '
')],
[('', _('Course Adviser'), '
')],
[('', _('Head of Department'), '
')],
[('', _('Dean of School'))]
)
def render(self):
portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language)
Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language)
Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language)
CC = translate(_('Cat.'), target_language=portal_language)
Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
studentview = StudentBasePDFFormPage(self.context.student,
self.request, self.omit_fields)
students_utils = getUtility(IStudentsUtils)
tabledata = []
tableheader = []
for i in range(1,7):
tabledata.append(sorted(
[value for value in self.context.values() if value.semester == i],
key=lambda value: str(value.semester) + value.code))
tableheader.append([(Code,'code', 2.5),
(Title,'title', 5),
(Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
(Cred, 'credits', 1.5),
(CC, 'course_category', 1.2),
(Score, 'score', 1.5),
(Grade, 'grade', 1.5),
])
return students_utils.renderPDF(
self, 'course_registration_slip.pdf',
self.context.student, studentview,
tableheader=tableheader,
tabledata=tabledata,
signatures=self._signatures(),
omit_fields=self.omit_fields
)