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

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

Adjust tests.

Disable hostel booking fee payment.

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