1 | ## $Id: viewlets.py 15802 2019-11-12 22:16:57Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2011 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 | ## |
---|
18 | |
---|
19 | import grok |
---|
20 | from zope.component import getUtility |
---|
21 | from waeup.kofa.interfaces import REQUESTED |
---|
22 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
23 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
24 | from kofacustom.iuokada.students.interfaces import ( |
---|
25 | ICustomStudentStudyCourse, ICustomStudentStudyLevel) |
---|
26 | from waeup.kofa.students.fileviewlets import ( |
---|
27 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
28 | from waeup.kofa.students.browser import ( |
---|
29 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
30 | StudyLevelDisplayFormPage, StudentBaseDisplayFormPage) |
---|
31 | |
---|
32 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
33 | |
---|
34 | class GetMatricNumberActionButton(ManageActionButton): |
---|
35 | grok.order(10) |
---|
36 | grok.context(IStudent) |
---|
37 | grok.view(StudentBaseDisplayFormPage) |
---|
38 | grok.require('waeup.viewStudent') |
---|
39 | icon = 'actionicon_count.png' |
---|
40 | text = _('Get Matriculation Number') |
---|
41 | |
---|
42 | @property |
---|
43 | def target_url(self): |
---|
44 | students_utils = getUtility(IStudentsUtils) |
---|
45 | if self.context.matric_number: |
---|
46 | return '' |
---|
47 | error, matric_number = students_utils.constructMatricNumber( |
---|
48 | self.context) |
---|
49 | if error: |
---|
50 | return '' |
---|
51 | return self.view.url(self.view.context, 'get_matric_number') |
---|
52 | |
---|
53 | # Signature |
---|
54 | |
---|
55 | class SignatureDisplay(StudentFileDisplay): |
---|
56 | """Signature display viewlet. |
---|
57 | """ |
---|
58 | grok.order(2) |
---|
59 | label = _(u'Signature') |
---|
60 | title = _(u'Signature Scan') |
---|
61 | download_name = u'signature' |
---|
62 | |
---|
63 | class SignatureSlip(SignatureDisplay): |
---|
64 | grok.view(ExportPDFClearanceSlip) |
---|
65 | |
---|
66 | class SignatureUpload(StudentFileUpload): |
---|
67 | """Signature upload viewlet. |
---|
68 | """ |
---|
69 | grok.order(2) |
---|
70 | label = _(u'Signature') |
---|
71 | title = _(u'Signature Scan') |
---|
72 | download_name = u'signature' |
---|
73 | tab_redirect = '?tab2' |
---|
74 | |
---|
75 | class SignatureImage(StudentImage): |
---|
76 | """Renders acceptance letter scan. |
---|
77 | """ |
---|
78 | grok.name('signature') |
---|
79 | download_name = u'signature' |
---|
80 | |
---|
81 | # JAMB Result |
---|
82 | |
---|
83 | class JAMBResultDisplay(StudentFileDisplay): |
---|
84 | """JAMB Result display viewlet. |
---|
85 | """ |
---|
86 | grok.order(9) |
---|
87 | label = _(u'JAMB Result') |
---|
88 | title = _(u'JAMB Result') |
---|
89 | download_name = u'jamb' |
---|
90 | |
---|
91 | class JAMBResultSlip(JAMBResultDisplay): |
---|
92 | grok.view(ExportPDFClearanceSlip) |
---|
93 | |
---|
94 | class JAMBResultUpload(StudentFileUpload): |
---|
95 | """JAMB Result upload viewlet. |
---|
96 | """ |
---|
97 | grok.order(9) |
---|
98 | label = _(u'JAMB Result') |
---|
99 | title = _(u'JAMB Result Scan') |
---|
100 | download_name = u'jamb' |
---|
101 | |
---|
102 | class JAMBResultImage(StudentImage): |
---|
103 | """Renders JAMB Result scan. |
---|
104 | """ |
---|
105 | grok.name('jamb') |
---|
106 | download_name = u'jamb' |
---|
107 | |
---|