source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/browser.py @ 15089

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

Hide score on browser pages end slips.

  • Property svn:keywords set to Id
File size: 7.2 KB
Line 
1## $Id: browser.py 15089 2018-07-16 08:03: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.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,
29    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
30    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
31    ExportPDFTranscriptSlip,
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,
40    NigeriaExportPDFPaymentSlip,
41    NigeriaExportPDFClearanceSlip,
42    )
43
44from kofacustom.dspg.students.interfaces import (
45    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
46    ICustomStudentStudyLevel)
47from kofacustom.dspg.interfaces import MessageFactory as _
48
49class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
50    """ View to edit student clearance data by student
51    """
52
53    def dataNotComplete(self):
54        store = getUtility(IExtFileStore)
55        if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'):
56            return _('No birth certificate uploaded.')
57        if not store.getFileByContext(self.context, attr=u'lga_ident.jpg'):
58            return _('No LGA identification letter uploaded.')
59        if not store.getFileByContext(self.context, attr=u'o_level_result.jpg'):
60            return _('No O Level result uploaded.')
61        cm = getattr(self.context,'current_mode', None)
62        if cm and cm.startswith('nd'):
63            if not store.getFileByContext(self.context, attr=u'jamb_result.jpg'):
64                return _('No JAMB result uploaded.')
65        elif cm and cm.startswith('hnd'):
66            if not store.getFileByContext(self.context, attr=u'nd_result.jpg'):
67                return _('No ND result uploaded.')
68            if not store.getFileByContext(self.context, attr=u'it_letter.jpg'):
69                return _('No IT letter uploaded.')
70        return False
71
72class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
73    """ Page to display student study levels
74    """
75    grok.template('studylevelpage')
76
77class CustomStudyLevelEditFormPage(StudyLevelEditFormPage):
78    """ Page to edit the student study level data by students.
79
80    """
81    grok.template('studyleveleditpage')
82
83class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
84    """ Page to display course tickets
85    """
86    form_fields = grok.AutoFields(ICourseTicket).omit('score')
87
88class CustomExportPDFCourseRegistrationSlip(ExportPDFCourseRegistrationSlip):
89    """Deliver a PDF slip of the context.
90    """
91
92    def render(self):
93        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
94        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
95        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
96        Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language)
97        Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language)
98        Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language)
99        #Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language)
100        #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
101        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
102        studentview = StudentBasePDFFormPage(self.context.student,
103            self.request, self.omit_fields)
104        students_utils = getUtility(IStudentsUtils)
105
106        tabledata = []
107        tableheader = []
108        for i in range(1,7):
109            tabledata.append(sorted(
110                [value for value in self.context.values() if value.semester == i],
111                key=lambda value: str(value.semester) + value.code))
112            tableheader.append([(Code,'code', 2.5),
113                             (Title,'title', 5),
114                             (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
115                             (Cred, 'credits', 1.5),
116                             #(Mand, 'mandatory', 1.5),
117                             #(Score, 'score', 1.5),
118                             (Grade, 'grade', 1.5),
119                             #('Auto', 'automatic', 1.5)
120                             ])
121        return students_utils.renderPDF(
122            self, 'course_registration_slip.pdf',
123            self.context.student, studentview,
124            tableheader=tableheader,
125            tabledata=tabledata,
126            omit_fields=self.omit_fields
127            )
128
129
130class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip):
131    """Deliver a PDF slip of the context.
132    """
133
134    def render(self):
135        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
136        Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language)
137        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
138        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
139        Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language)
140        #Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
141        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
142        studentview = StudentBasePDFFormPage(self.context.student,
143            self.request, self.omit_fields)
144        students_utils = getUtility(IStudentsUtils)
145
146        tableheader = [(Code,'code', 2.5),
147                         (Title,'title', 8.5),
148                         (Term, 'semester', 1.5),
149                         (Cred, 'credits', 1.5),
150                         #(Score, 'score', 1.5),
151                         (Grade, 'grade', 1.5),
152                         ]
153
154        return students_utils.renderPDFTranscript(
155            self, 'transcript.pdf',
156            self.context.student, studentview,
157            omit_fields=self.omit_fields,
158            tableheader=tableheader,
159            signatures=self._signatures(),
160            sigs_in_footer=self._sigsInFooter(),
161            )
Note: See TracBrowser for help on using the repository browser.