source: main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/browser.py @ 15131

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

Hide score on browser pages end slips.

  • Property svn:keywords set to Id
File size: 6.2 KB
RevLine 
[10765]1## $Id: browser.py 15088 2018-07-16 07:56:40Z 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.schema.interfaces import ConstraintNotSatisfied
21from zope.component import getUtility
22from hurry.workflow.interfaces import IWorkflowInfo
23from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
24from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
25from waeup.kofa.browser.layout import KofaEditFormPage
26from waeup.kofa.browser.layout import action, jsaction
27from waeup.kofa.students.browser import (
28    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
[13062]29    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
[10765]30    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
[15088]31    BedTicketAddPage, ExportPDFTranscriptSlip,
[10765]32    msave, emit_lock_message)
33from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
34from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
35from kofacustom.nigeria.students.browser import (
36    NigeriaOnlinePaymentDisplayFormPage,
37    NigeriaStudentBaseManageFormPage,
38    NigeriaStudentClearanceEditFormPage,
39    NigeriaOnlinePaymentAddFormPage,
[13062]40    NigeriaExportPDFPaymentSlip,
41    NigeriaExportPDFClearanceSlip,
[10765]42    )
43
[15000]44from kofacustom.edopoly.students.interfaces import (
[10765]45    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
46    ICustomStudentStudyLevel)
[15000]47from kofacustom.edopoly.interfaces import MessageFactory as _
[10765]48
[15017]49class CustomBedTicketAddPage(BedTicketAddPage):
50    with_ac = False
[15088]51
52class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
53    """ Page to display student study levels
54    """
55    grok.template('studylevelpage')
56
57class CustomStudyLevelEditFormPage(StudyLevelEditFormPage):
58    """ Page to edit the student study level data by students.
59
60    """
61    grok.template('studyleveleditpage')
62
63class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
64    """ Page to display course tickets
65    """
66    form_fields = grok.AutoFields(ICourseTicket).omit('score')
67
68class CustomExportPDFCourseRegistrationSlip(ExportPDFCourseRegistrationSlip):
69    """Deliver a PDF slip of the context.
70    """
71
72    def render(self):
73        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
74        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
75        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
76        Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language)
77        Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language)
78        Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language)
79        #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language)
80        #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
81        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
82        studentview = StudentBasePDFFormPage(self.context.student,
83            self.request, self.omit_fields)
84        students_utils = getUtility(IStudentsUtils)
85
86        tabledata = []
87        tableheader = []
88        for i in range(1,7):
89            tabledata.append(sorted(
90                [value for value in self.context.values() if value.semester == i],
91                key=lambda value: str(value.semester) + value.code))
92            tableheader.append([(Code,'code', 2.5),
93                             (Title,'title', 5),
94                             (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
95                             (Cred, 'credits', 1.5),
96                             #(Mand, 'mandatory', 1.5),
97                             #(Score, 'score', 1.5),
98                             (Grade, 'grade', 1.5),
99                             #('Auto', 'automatic', 1.5)
100                             ])
101        return students_utils.renderPDF(
102            self, 'course_registration_slip.pdf',
103            self.context.student, studentview,
104            tableheader=tableheader,
105            tabledata=tabledata,
106            omit_fields=self.omit_fields
107            )
108
109
110class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip):
111    """Deliver a PDF slip of the context.
112    """
113
114    def render(self):
115        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
116        Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language)
117        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
118        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
119        Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language)
120        #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
121        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
122        studentview = StudentBasePDFFormPage(self.context.student,
123            self.request, self.omit_fields)
124        students_utils = getUtility(IStudentsUtils)
125
126        tableheader = [(Code,'code', 2.5),
127                         (Title,'title', 8.5),
128                         (Term, 'semester', 1.5),
129                         (Cred, 'credits', 1.5),
130                         #(Score, 'score', 1.5),
131                         (Grade, 'grade', 1.5),
132                         ]
133
134        return students_utils.renderPDFTranscript(
135            self, 'transcript.pdf',
136            self.context.student, studentview,
137            omit_fields=self.omit_fields,
138            tableheader=tableheader,
139            signatures=self._signatures(),
140            sigs_in_footer=self._sigsInFooter(),
141            )
Note: See TracBrowser for help on using the repository browser.