[10765] | 1 | ## $Id: viewlets.py 15700 2019-10-24 09:19:46Z 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 | download_name = u'nd_result' |
---|
| 91 | |
---|
| 92 | @property |
---|
| 93 | def show_viewlet(self): |
---|
| 94 | students_utils = getUtility(IStudentsUtils) |
---|
| 95 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 96 | return False |
---|
[14883] | 97 | cm = getattr(self.context,'current_mode', None) |
---|
| 98 | return cm and cm.startswith('hnd') |
---|
[14882] | 99 | |
---|
| 100 | class NDResultImage(StudentImage): |
---|
| 101 | """Renders ND Result scan. |
---|
| 102 | """ |
---|
| 103 | grok.name('nd_result') |
---|
| 104 | download_name = u'nd_result' |
---|
| 105 | |
---|
| 106 | # O Level Result |
---|
| 107 | |
---|
| 108 | class OLevelResultDisplay(StudentFileDisplay): |
---|
| 109 | """O Level Result display viewlet. |
---|
| 110 | """ |
---|
| 111 | grok.order(19) |
---|
| 112 | label = _(u'O Level Result') |
---|
| 113 | title = _(u'O Level Result') |
---|
| 114 | download_name = u'o_level_result' |
---|
| 115 | |
---|
| 116 | class OLevelResultSlip(OLevelResultDisplay): |
---|
| 117 | grok.view(ExportPDFClearanceSlip) |
---|
| 118 | |
---|
| 119 | class OLevelResultUpload(StudentFileUpload): |
---|
| 120 | """O Level Result upload viewlet. |
---|
| 121 | """ |
---|
| 122 | grok.order(19) |
---|
| 123 | label = _(u'O Level Result') |
---|
| 124 | title = _(u'O Level Result Scan') |
---|
| 125 | download_name = u'o_level_result' |
---|
| 126 | |
---|
| 127 | class OLevelResultImage(StudentImage): |
---|
| 128 | """Renders O Level Result scan. |
---|
| 129 | """ |
---|
| 130 | grok.name('o_level_result') |
---|
| 131 | download_name = u'o_level_result' |
---|
| 132 | |
---|
[15700] | 133 | # O Level Result 2 |
---|
| 134 | |
---|
| 135 | class OLevelResult2Display(StudentFileDisplay): |
---|
| 136 | """O Level Result 2 display viewlet. |
---|
| 137 | """ |
---|
| 138 | grok.order(19) |
---|
| 139 | label = _(u'O Level Result 2') |
---|
| 140 | title = _(u'O Level Result 2') |
---|
| 141 | download_name = u'o_level_result_2' |
---|
| 142 | |
---|
| 143 | class OLevelResult2Slip(OLevelResult2Display): |
---|
| 144 | grok.view(ExportPDFClearanceSlip) |
---|
| 145 | |
---|
| 146 | class OLevelResult2Upload(StudentFileUpload): |
---|
| 147 | """O Level Result 2 upload viewlet. |
---|
| 148 | """ |
---|
| 149 | grok.order(19) |
---|
| 150 | label = _(u'O Level Result 2') |
---|
| 151 | title = _(u'O Level Result Scan 2') |
---|
| 152 | download_name = u'o_level_result_2' |
---|
| 153 | |
---|
| 154 | class OLevelResult2Image(StudentImage): |
---|
| 155 | """Renders O Level Result 2 scan. |
---|
| 156 | """ |
---|
| 157 | grok.name('o_level_result_2') |
---|
| 158 | download_name = u'o_level_result_2' |
---|
| 159 | |
---|
[14882] | 160 | # IT Letter |
---|
| 161 | |
---|
| 162 | class ITLetterDisplay(StudentFileDisplay): |
---|
| 163 | """IT Letter display viewlet. |
---|
| 164 | """ |
---|
| 165 | grok.order(19) |
---|
| 166 | label = _(u'IT Letter') |
---|
| 167 | title = _(u'IT Letter') |
---|
| 168 | download_name = u'it_letter' |
---|
| 169 | |
---|
| 170 | class ITLetterSlip(ITLetterDisplay): |
---|
| 171 | grok.view(ExportPDFClearanceSlip) |
---|
| 172 | |
---|
| 173 | class ITLetterUpload(StudentFileUpload): |
---|
| 174 | """IT Letter upload viewlet. |
---|
| 175 | """ |
---|
| 176 | grok.order(19) |
---|
| 177 | label = _(u'IT Letter') |
---|
| 178 | title = _(u'IT Letter Scan') |
---|
| 179 | download_name = u'it_letter' |
---|
| 180 | |
---|
| 181 | @property |
---|
| 182 | def show_viewlet(self): |
---|
| 183 | students_utils = getUtility(IStudentsUtils) |
---|
| 184 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 185 | return False |
---|
[14883] | 186 | cm = getattr(self.context,'current_mode', None) |
---|
| 187 | return cm and cm.startswith('hnd') |
---|
[14882] | 188 | |
---|
| 189 | class ITLetterImage(StudentImage): |
---|
| 190 | """Renders IT Letter scan. |
---|
| 191 | """ |
---|
| 192 | grok.name('it_letter') |
---|
| 193 | download_name = u'it_letter' |
---|
| 194 | |
---|
| 195 | # JAMB Result |
---|
| 196 | |
---|
| 197 | class JAMBResultDisplay(StudentFileDisplay): |
---|
| 198 | """JAMB Result display viewlet. |
---|
| 199 | """ |
---|
| 200 | grok.order(19) |
---|
| 201 | label = _(u'JAMB Result') |
---|
| 202 | title = _(u'JAMB Result') |
---|
| 203 | download_name = u'jamb_result' |
---|
| 204 | |
---|
| 205 | class JAMBResultSlip(JAMBResultDisplay): |
---|
| 206 | grok.view(ExportPDFClearanceSlip) |
---|
| 207 | |
---|
| 208 | class JAMBResultUpload(StudentFileUpload): |
---|
| 209 | """JAMB Result upload viewlet. |
---|
| 210 | """ |
---|
| 211 | grok.order(19) |
---|
| 212 | title = _(u'JAMB Result Scan') |
---|
| 213 | download_name = u'jamb_result' |
---|
| 214 | |
---|
| 215 | @property |
---|
| 216 | def label(self): |
---|
[14883] | 217 | cm = getattr(self.context,'current_mode', None) |
---|
| 218 | if cm and cm.startswith('hnd'): |
---|
[14882] | 219 | return u'JAMB Result / ND Admission Letter (optional)' |
---|
| 220 | else: |
---|
| 221 | return u'JAMB Result' |
---|
| 222 | |
---|
| 223 | class JAMBResultImage(StudentImage): |
---|
| 224 | """Renders JAMB Result scan. |
---|
| 225 | """ |
---|
| 226 | grok.name('jamb_result') |
---|
| 227 | download_name = u'jamb_result' |
---|
[14913] | 228 | |
---|
| 229 | # Additional Document |
---|
| 230 | |
---|
| 231 | class AdditionalDocDisplay(StudentFileDisplay): |
---|
| 232 | """Additional Document display viewlet. |
---|
| 233 | """ |
---|
| 234 | grok.order(19) |
---|
| 235 | label = _(u'Additional Document') |
---|
| 236 | title = _(u'Additional Document') |
---|
| 237 | download_name = u'additional_doc' |
---|
| 238 | |
---|
| 239 | class AdditionalDocSlip(AdditionalDocDisplay): |
---|
| 240 | grok.view(ExportPDFClearanceSlip) |
---|
| 241 | |
---|
| 242 | class AdditionalDocUpload(StudentFileUpload): |
---|
| 243 | """Additional Document upload viewlet. |
---|
| 244 | """ |
---|
| 245 | grok.order(19) |
---|
| 246 | title = _(u'Additional Document Scan') |
---|
| 247 | download_name = u'additional_doc' |
---|
| 248 | label = _(u'Additional Document') |
---|
| 249 | |
---|
| 250 | class AdditionalDocImage(StudentImage): |
---|
| 251 | """Renders Additional Document scan. |
---|
| 252 | """ |
---|
| 253 | grok.name('additional_doc') |
---|
| 254 | download_name = u'additional_doc' |
---|