[10765] | 1 | ## $Id: viewlets.py 15289 2019-01-10 10:16:17Z 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 |
---|
[14882] | 20 | from zope.component import getUtility |
---|
[10765] | 21 | from waeup.kofa.interfaces import REQUESTED |
---|
| 22 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
[15288] | 23 | from waeup.kofa.students.interfaces import IStudentsUtils, IStudent |
---|
[12430] | 24 | from waeup.kofa.students.fileviewlets import ( |
---|
[12450] | 25 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
[15289] | 26 | from waeup.kofa.students.workflow import PAID |
---|
[10765] | 27 | from waeup.kofa.students.browser import ( |
---|
[13062] | 28 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
[15288] | 29 | StudyLevelDisplayFormPage, StudentBaseDisplayFormPage) |
---|
| 30 | from kofacustom.dspg.students.interfaces import ( |
---|
| 31 | ICustomStudentStudyCourse, ICustomStudentStudyLevel) |
---|
[10765] | 32 | |
---|
| 33 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
[14882] | 34 | |
---|
[15288] | 35 | class GetMatricNumberActionButton(ManageActionButton): |
---|
| 36 | grok.order(10) |
---|
| 37 | grok.context(IStudent) |
---|
| 38 | grok.view(StudentBaseDisplayFormPage) |
---|
| 39 | grok.require('waeup.viewStudent') |
---|
| 40 | #grok.require('waeup.manageStudent') |
---|
| 41 | icon = 'actionicon_count.png' |
---|
| 42 | text = _('Get Matriculation Number') |
---|
| 43 | |
---|
| 44 | @property |
---|
| 45 | def target_url(self): |
---|
| 46 | students_utils = getUtility(IStudentsUtils) |
---|
| 47 | if self.context.matric_number: |
---|
| 48 | return '' |
---|
| 49 | error, matric_number = students_utils.constructMatricNumber( |
---|
| 50 | self.context) |
---|
| 51 | if error: |
---|
| 52 | return '' |
---|
| 53 | return self.view.url(self.view.context, 'get_matric_number') |
---|
| 54 | |
---|
| 55 | class MatricNumberSlipActionButton(ManageActionButton): |
---|
| 56 | grok.order(10) |
---|
| 57 | grok.context(IStudent) |
---|
| 58 | grok.view(StudentBaseDisplayFormPage) |
---|
| 59 | grok.require('waeup.viewStudent') |
---|
| 60 | icon = 'actionicon_pdf.png' |
---|
| 61 | text = _('Download matriculation number slip') |
---|
| 62 | target = 'matric_number_slip.pdf' |
---|
| 63 | |
---|
| 64 | @property |
---|
| 65 | def target_url(self): |
---|
| 66 | if self.context.state not in (PAID,) or not self.context.is_fresh \ |
---|
| 67 | or not self.context.matric_number: |
---|
| 68 | return '' |
---|
| 69 | return self.view.url(self.view.context, self.target) |
---|
| 70 | |
---|
[14882] | 71 | # ND Result |
---|
| 72 | |
---|
| 73 | class NDResultDisplay(StudentFileDisplay): |
---|
| 74 | """ND Result display viewlet. |
---|
| 75 | """ |
---|
| 76 | grok.order(19) |
---|
| 77 | label = _(u'ND Result') |
---|
| 78 | title = _(u'ND Result') |
---|
| 79 | download_name = u'nd_result' |
---|
| 80 | |
---|
| 81 | class NDResultSlip(NDResultDisplay): |
---|
| 82 | grok.view(ExportPDFClearanceSlip) |
---|
| 83 | |
---|
| 84 | class NDResultUpload(StudentFileUpload): |
---|
| 85 | """ND Result upload viewlet. |
---|
| 86 | """ |
---|
| 87 | grok.order(19) |
---|
| 88 | label = _(u'ND Result') |
---|
| 89 | title = _(u'ND Result Scan') |
---|
| 90 | mus = 1024 * 250 |
---|
| 91 | download_name = u'nd_result' |
---|
| 92 | |
---|
| 93 | @property |
---|
| 94 | def show_viewlet(self): |
---|
| 95 | students_utils = getUtility(IStudentsUtils) |
---|
| 96 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 97 | return False |
---|
[14883] | 98 | cm = getattr(self.context,'current_mode', None) |
---|
| 99 | return cm and cm.startswith('hnd') |
---|
[14882] | 100 | |
---|
| 101 | class NDResultImage(StudentImage): |
---|
| 102 | """Renders ND Result scan. |
---|
| 103 | """ |
---|
| 104 | grok.name('nd_result') |
---|
| 105 | download_name = u'nd_result' |
---|
| 106 | |
---|
| 107 | # O Level Result |
---|
| 108 | |
---|
| 109 | class OLevelResultDisplay(StudentFileDisplay): |
---|
| 110 | """O Level Result display viewlet. |
---|
| 111 | """ |
---|
| 112 | grok.order(19) |
---|
| 113 | label = _(u'O Level Result') |
---|
| 114 | title = _(u'O Level Result') |
---|
| 115 | download_name = u'o_level_result' |
---|
| 116 | |
---|
| 117 | class OLevelResultSlip(OLevelResultDisplay): |
---|
| 118 | grok.view(ExportPDFClearanceSlip) |
---|
| 119 | |
---|
| 120 | class OLevelResultUpload(StudentFileUpload): |
---|
| 121 | """O Level Result upload viewlet. |
---|
| 122 | """ |
---|
| 123 | grok.order(19) |
---|
| 124 | label = _(u'O Level Result') |
---|
| 125 | title = _(u'O Level Result Scan') |
---|
| 126 | mus = 1024 * 250 |
---|
| 127 | download_name = u'o_level_result' |
---|
| 128 | |
---|
| 129 | class OLevelResultImage(StudentImage): |
---|
| 130 | """Renders O Level Result scan. |
---|
| 131 | """ |
---|
| 132 | grok.name('o_level_result') |
---|
| 133 | download_name = u'o_level_result' |
---|
| 134 | |
---|
| 135 | # IT Letter |
---|
| 136 | |
---|
| 137 | class ITLetterDisplay(StudentFileDisplay): |
---|
| 138 | """IT Letter display viewlet. |
---|
| 139 | """ |
---|
| 140 | grok.order(19) |
---|
| 141 | label = _(u'IT Letter') |
---|
| 142 | title = _(u'IT Letter') |
---|
| 143 | download_name = u'it_letter' |
---|
| 144 | |
---|
| 145 | class ITLetterSlip(ITLetterDisplay): |
---|
| 146 | grok.view(ExportPDFClearanceSlip) |
---|
| 147 | |
---|
| 148 | class ITLetterUpload(StudentFileUpload): |
---|
| 149 | """IT Letter upload viewlet. |
---|
| 150 | """ |
---|
| 151 | grok.order(19) |
---|
| 152 | label = _(u'IT Letter') |
---|
| 153 | title = _(u'IT Letter Scan') |
---|
| 154 | mus = 1024 * 250 |
---|
| 155 | download_name = u'it_letter' |
---|
| 156 | |
---|
| 157 | @property |
---|
| 158 | def show_viewlet(self): |
---|
| 159 | students_utils = getUtility(IStudentsUtils) |
---|
| 160 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 161 | return False |
---|
[14883] | 162 | cm = getattr(self.context,'current_mode', None) |
---|
| 163 | return cm and cm.startswith('hnd') |
---|
[14882] | 164 | |
---|
| 165 | class ITLetterImage(StudentImage): |
---|
| 166 | """Renders IT Letter scan. |
---|
| 167 | """ |
---|
| 168 | grok.name('it_letter') |
---|
| 169 | download_name = u'it_letter' |
---|
| 170 | |
---|
| 171 | # JAMB Result |
---|
| 172 | |
---|
| 173 | class JAMBResultDisplay(StudentFileDisplay): |
---|
| 174 | """JAMB Result display viewlet. |
---|
| 175 | """ |
---|
| 176 | grok.order(19) |
---|
| 177 | label = _(u'JAMB Result') |
---|
| 178 | title = _(u'JAMB Result') |
---|
| 179 | download_name = u'jamb_result' |
---|
| 180 | |
---|
| 181 | class JAMBResultSlip(JAMBResultDisplay): |
---|
| 182 | grok.view(ExportPDFClearanceSlip) |
---|
| 183 | |
---|
| 184 | class JAMBResultUpload(StudentFileUpload): |
---|
| 185 | """JAMB Result upload viewlet. |
---|
| 186 | """ |
---|
| 187 | grok.order(19) |
---|
| 188 | title = _(u'JAMB Result Scan') |
---|
| 189 | mus = 1024 * 250 |
---|
| 190 | download_name = u'jamb_result' |
---|
| 191 | |
---|
| 192 | @property |
---|
| 193 | def label(self): |
---|
[14883] | 194 | cm = getattr(self.context,'current_mode', None) |
---|
| 195 | if cm and cm.startswith('hnd'): |
---|
[14882] | 196 | return u'JAMB Result / ND Admission Letter (optional)' |
---|
| 197 | else: |
---|
| 198 | return u'JAMB Result' |
---|
| 199 | |
---|
| 200 | class JAMBResultImage(StudentImage): |
---|
| 201 | """Renders JAMB Result scan. |
---|
| 202 | """ |
---|
| 203 | grok.name('jamb_result') |
---|
| 204 | download_name = u'jamb_result' |
---|
[14913] | 205 | |
---|
| 206 | # Additional Document |
---|
| 207 | |
---|
| 208 | class AdditionalDocDisplay(StudentFileDisplay): |
---|
| 209 | """Additional Document display viewlet. |
---|
| 210 | """ |
---|
| 211 | grok.order(19) |
---|
| 212 | label = _(u'Additional Document') |
---|
| 213 | title = _(u'Additional Document') |
---|
| 214 | download_name = u'additional_doc' |
---|
| 215 | |
---|
| 216 | class AdditionalDocSlip(AdditionalDocDisplay): |
---|
| 217 | grok.view(ExportPDFClearanceSlip) |
---|
| 218 | |
---|
| 219 | class AdditionalDocUpload(StudentFileUpload): |
---|
| 220 | """Additional Document upload viewlet. |
---|
| 221 | """ |
---|
| 222 | grok.order(19) |
---|
| 223 | title = _(u'Additional Document Scan') |
---|
| 224 | mus = 1024 * 250 |
---|
| 225 | download_name = u'additional_doc' |
---|
| 226 | label = _(u'Additional Document') |
---|
| 227 | |
---|
| 228 | class AdditionalDocImage(StudentImage): |
---|
| 229 | """Renders Additional Document scan. |
---|
| 230 | """ |
---|
| 231 | grok.name('additional_doc') |
---|
| 232 | download_name = u'additional_doc' |
---|