1 | ## $Id: viewlets.py 12452 2015-01-12 11:17:16Z 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 waeup.kofa.interfaces import REQUESTED |
---|
21 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
22 | from waeup.uniben.students.interfaces import ( |
---|
23 | ICustomStudentStudyCourse, ICustomStudentStudyLevel, |
---|
24 | ICustomStudent, ) |
---|
25 | from waeup.kofa.students.fileviewlets import ( |
---|
26 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
27 | from waeup.kofa.students.browser import ( |
---|
28 | ExportPDFClearanceSlipPage, StudyCourseDisplayFormPage, |
---|
29 | StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage) |
---|
30 | |
---|
31 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
32 | |
---|
33 | class StudyCourseEditActionButton(ManageActionButton): |
---|
34 | grok.order(1) |
---|
35 | grok.context(ICustomStudentStudyCourse) |
---|
36 | grok.view(StudyCourseDisplayFormPage) |
---|
37 | grok.require('waeup.clearStudent') |
---|
38 | text = _('Edit level') |
---|
39 | target = 'edit_level' |
---|
40 | |
---|
41 | @property |
---|
42 | def target_url(self): |
---|
43 | if self.context.is_current and self.context.student.state == REQUESTED: |
---|
44 | return self.view.url(self.view.context, self.target) |
---|
45 | return False |
---|
46 | |
---|
47 | class CourseResultSlipActionButton(ManageActionButton): |
---|
48 | grok.order(6) |
---|
49 | grok.context(ICustomStudentStudyLevel) |
---|
50 | grok.view(StudyLevelDisplayFormPage) |
---|
51 | grok.require('waeup.viewStudent') |
---|
52 | icon = 'actionicon_pdf.png' |
---|
53 | text = _('Download course result slip') |
---|
54 | target = 'course_result_slip.pdf' |
---|
55 | |
---|
56 | @property |
---|
57 | def target_url(self): |
---|
58 | return self.view.url(self.view.context, self.target) |
---|
59 | |
---|
60 | |
---|
61 | class ClearanceInvitationSlipActionButton(ManageActionButton): |
---|
62 | grok.order(5) |
---|
63 | grok.context(ICustomStudent) |
---|
64 | grok.view(StudentClearanceDisplayFormPage) |
---|
65 | grok.require('waeup.viewStudent') |
---|
66 | icon = 'actionicon_pdf.png' |
---|
67 | text = _('Download clearance invitation slip') |
---|
68 | target = 'clearance_invitation_slip.pdf' |
---|
69 | |
---|
70 | @property |
---|
71 | def target_url(self): |
---|
72 | if self.context.student.state == REQUESTED \ |
---|
73 | and self.context.student.physical_clearance_date: |
---|
74 | return self.view.url(self.view.context, self.target) |
---|
75 | return False |
---|
76 | |
---|
77 | |
---|
78 | # JAMB Letter |
---|
79 | |
---|
80 | class JAMBLetterDisplay(StudentFileDisplay): |
---|
81 | """JAMB Letter display viewlet. |
---|
82 | """ |
---|
83 | grok.order(19) |
---|
84 | label = _(u'JAMB Letter') |
---|
85 | title = _(u'JAMB Letter') |
---|
86 | download_name = u'jamb_letter' |
---|
87 | |
---|
88 | class JAMBLetterSlip(JAMBLetterDisplay): |
---|
89 | grok.view(ExportPDFClearanceSlipPage) |
---|
90 | |
---|
91 | class JAMBLetterUpload(StudentFileUpload): |
---|
92 | """JAMB Letter upload viewlet. |
---|
93 | """ |
---|
94 | grok.order(19) |
---|
95 | label = _(u'JAMB Letter') |
---|
96 | title = _(u'JAMB Letter Scan') |
---|
97 | mus = 1024 * 150 |
---|
98 | download_name = u'jamb_letter' |
---|
99 | |
---|
100 | class JAMBLetterImage(StudentImage): |
---|
101 | """Renders JAMB Letter scan. |
---|
102 | """ |
---|
103 | grok.name('jamb_letter') |
---|
104 | download_name = u'jamb_letter' |
---|
105 | |
---|
106 | # Affidavit of Non-Membership of Secret Cults |
---|
107 | |
---|
108 | class SecrCultsStatementDisplay(StudentFileDisplay): |
---|
109 | """Affidavit of Non-Membership of Secret Cults display viewlet. |
---|
110 | """ |
---|
111 | grok.order(20) |
---|
112 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
113 | title = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
114 | download_name = u'secr_cults' |
---|
115 | |
---|
116 | class SecrCultsStatementSlip(SecrCultsStatementDisplay): |
---|
117 | grok.view(ExportPDFClearanceSlipPage) |
---|
118 | |
---|
119 | class SecrCultsStatementUpload(StudentFileUpload): |
---|
120 | """Affidavit of Non-Membership of Secret Cults upload viewlet. |
---|
121 | """ |
---|
122 | grok.order(20) |
---|
123 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
124 | title = _(u'Affidavit of Non-Membership of Secret Cults Scan') |
---|
125 | mus = 1024 * 150 |
---|
126 | download_name = u'secr_cults' |
---|
127 | |
---|
128 | class SecrCultsStatementImage(StudentImage): |
---|
129 | """Renders Affidavit of Non-Membership of Secret Cults scan. |
---|
130 | """ |
---|
131 | grok.name('secr_cults') |
---|
132 | download_name = u'secr_cults' |
---|
133 | |
---|
134 | # Fingerprints |
---|
135 | |
---|
136 | class LeftThumbPrintDisplay(StudentFileDisplay): |
---|
137 | """Left thumb fingerprint display viewlet. |
---|
138 | """ |
---|
139 | grok.order(21) |
---|
140 | label = _(u'Left Thumb Fingerprint') |
---|
141 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
142 | download_name = u'finger1.fpm' |
---|
143 | |
---|
144 | class LeftThumbPrintSlip(LeftThumbPrintDisplay): |
---|
145 | """Mentions scanned fingerprint on slip. |
---|
146 | |
---|
147 | Fingerprint minutiae is not printet. |
---|
148 | """ |
---|
149 | grok.view(ExportPDFClearanceSlipPage) |
---|
150 | |
---|
151 | class LeftThumbPrintUpload(StudentFileUpload): |
---|
152 | """Left thumb fingerprint upload viewlet. |
---|
153 | """ |
---|
154 | grok.order(21) |
---|
155 | grok.require('waeup.manageStudent') |
---|
156 | label = _(u'Left Thumb Fingerprint') |
---|
157 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
158 | mus = 1024 * 5 |
---|
159 | download_name = u'finger1.fpm' |
---|
160 | |
---|
161 | class LeftThumbPrintImage(StudentImage): |
---|
162 | """Renders left thumb fingerprint minutiae for download. |
---|
163 | """ |
---|
164 | grok.name('finger1.fpm') |
---|
165 | download_name = u'finger1.fpm' |
---|