[10765] | 1 | ## $Id: viewlets.py 14913 2017-11-29 10:57:30Z 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 |
---|
[14882] | 23 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[14716] | 24 | from kofacustom.dspg.students.interfaces import ( |
---|
[10765] | 25 | ICustomStudentStudyCourse, ICustomStudentStudyLevel) |
---|
[12430] | 26 | from waeup.kofa.students.fileviewlets import ( |
---|
[12450] | 27 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
[10765] | 28 | from waeup.kofa.students.browser import ( |
---|
[13062] | 29 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
[10765] | 30 | StudyLevelDisplayFormPage) |
---|
| 31 | |
---|
| 32 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
[14882] | 33 | |
---|
| 34 | # ND Result |
---|
| 35 | |
---|
| 36 | class NDResultDisplay(StudentFileDisplay): |
---|
| 37 | """ND Result display viewlet. |
---|
| 38 | """ |
---|
| 39 | grok.order(19) |
---|
| 40 | label = _(u'ND Result') |
---|
| 41 | title = _(u'ND Result') |
---|
| 42 | download_name = u'nd_result' |
---|
| 43 | |
---|
| 44 | class NDResultSlip(NDResultDisplay): |
---|
| 45 | grok.view(ExportPDFClearanceSlip) |
---|
| 46 | |
---|
| 47 | class NDResultUpload(StudentFileUpload): |
---|
| 48 | """ND Result upload viewlet. |
---|
| 49 | """ |
---|
| 50 | grok.order(19) |
---|
| 51 | label = _(u'ND Result') |
---|
| 52 | title = _(u'ND Result Scan') |
---|
| 53 | mus = 1024 * 250 |
---|
| 54 | download_name = u'nd_result' |
---|
| 55 | |
---|
| 56 | @property |
---|
| 57 | def show_viewlet(self): |
---|
| 58 | students_utils = getUtility(IStudentsUtils) |
---|
| 59 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 60 | return False |
---|
[14883] | 61 | cm = getattr(self.context,'current_mode', None) |
---|
| 62 | return cm and cm.startswith('hnd') |
---|
[14882] | 63 | |
---|
| 64 | class NDResultImage(StudentImage): |
---|
| 65 | """Renders ND Result scan. |
---|
| 66 | """ |
---|
| 67 | grok.name('nd_result') |
---|
| 68 | download_name = u'nd_result' |
---|
| 69 | |
---|
| 70 | # O Level Result |
---|
| 71 | |
---|
| 72 | class OLevelResultDisplay(StudentFileDisplay): |
---|
| 73 | """O Level Result display viewlet. |
---|
| 74 | """ |
---|
| 75 | grok.order(19) |
---|
| 76 | label = _(u'O Level Result') |
---|
| 77 | title = _(u'O Level Result') |
---|
| 78 | download_name = u'o_level_result' |
---|
| 79 | |
---|
| 80 | class OLevelResultSlip(OLevelResultDisplay): |
---|
| 81 | grok.view(ExportPDFClearanceSlip) |
---|
| 82 | |
---|
| 83 | class OLevelResultUpload(StudentFileUpload): |
---|
| 84 | """O Level Result upload viewlet. |
---|
| 85 | """ |
---|
| 86 | grok.order(19) |
---|
| 87 | label = _(u'O Level Result') |
---|
| 88 | title = _(u'O Level Result Scan') |
---|
| 89 | mus = 1024 * 250 |
---|
| 90 | download_name = u'o_level_result' |
---|
| 91 | |
---|
| 92 | class OLevelResultImage(StudentImage): |
---|
| 93 | """Renders O Level Result scan. |
---|
| 94 | """ |
---|
| 95 | grok.name('o_level_result') |
---|
| 96 | download_name = u'o_level_result' |
---|
| 97 | |
---|
| 98 | # IT Letter |
---|
| 99 | |
---|
| 100 | class ITLetterDisplay(StudentFileDisplay): |
---|
| 101 | """IT Letter display viewlet. |
---|
| 102 | """ |
---|
| 103 | grok.order(19) |
---|
| 104 | label = _(u'IT Letter') |
---|
| 105 | title = _(u'IT Letter') |
---|
| 106 | download_name = u'it_letter' |
---|
| 107 | |
---|
| 108 | class ITLetterSlip(ITLetterDisplay): |
---|
| 109 | grok.view(ExportPDFClearanceSlip) |
---|
| 110 | |
---|
| 111 | class ITLetterUpload(StudentFileUpload): |
---|
| 112 | """IT Letter upload viewlet. |
---|
| 113 | """ |
---|
| 114 | grok.order(19) |
---|
| 115 | label = _(u'IT Letter') |
---|
| 116 | title = _(u'IT Letter Scan') |
---|
| 117 | mus = 1024 * 250 |
---|
| 118 | download_name = u'it_letter' |
---|
| 119 | |
---|
| 120 | @property |
---|
| 121 | def show_viewlet(self): |
---|
| 122 | students_utils = getUtility(IStudentsUtils) |
---|
| 123 | if self.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS: |
---|
| 124 | return False |
---|
[14883] | 125 | cm = getattr(self.context,'current_mode', None) |
---|
| 126 | return cm and cm.startswith('hnd') |
---|
[14882] | 127 | |
---|
| 128 | class ITLetterImage(StudentImage): |
---|
| 129 | """Renders IT Letter scan. |
---|
| 130 | """ |
---|
| 131 | grok.name('it_letter') |
---|
| 132 | download_name = u'it_letter' |
---|
| 133 | |
---|
| 134 | # JAMB Result |
---|
| 135 | |
---|
| 136 | class JAMBResultDisplay(StudentFileDisplay): |
---|
| 137 | """JAMB Result display viewlet. |
---|
| 138 | """ |
---|
| 139 | grok.order(19) |
---|
| 140 | label = _(u'JAMB Result') |
---|
| 141 | title = _(u'JAMB Result') |
---|
| 142 | download_name = u'jamb_result' |
---|
| 143 | |
---|
| 144 | class JAMBResultSlip(JAMBResultDisplay): |
---|
| 145 | grok.view(ExportPDFClearanceSlip) |
---|
| 146 | |
---|
| 147 | class JAMBResultUpload(StudentFileUpload): |
---|
| 148 | """JAMB Result upload viewlet. |
---|
| 149 | """ |
---|
| 150 | grok.order(19) |
---|
| 151 | title = _(u'JAMB Result Scan') |
---|
| 152 | mus = 1024 * 250 |
---|
| 153 | download_name = u'jamb_result' |
---|
| 154 | |
---|
| 155 | @property |
---|
| 156 | def label(self): |
---|
[14883] | 157 | cm = getattr(self.context,'current_mode', None) |
---|
| 158 | if cm and cm.startswith('hnd'): |
---|
[14882] | 159 | return u'JAMB Result / ND Admission Letter (optional)' |
---|
| 160 | else: |
---|
| 161 | return u'JAMB Result' |
---|
| 162 | |
---|
| 163 | class JAMBResultImage(StudentImage): |
---|
| 164 | """Renders JAMB Result scan. |
---|
| 165 | """ |
---|
| 166 | grok.name('jamb_result') |
---|
| 167 | download_name = u'jamb_result' |
---|
[14913] | 168 | |
---|
| 169 | # Additional Document |
---|
| 170 | |
---|
| 171 | class AdditionalDocDisplay(StudentFileDisplay): |
---|
| 172 | """Additional Document display viewlet. |
---|
| 173 | """ |
---|
| 174 | grok.order(19) |
---|
| 175 | label = _(u'Additional Document') |
---|
| 176 | title = _(u'Additional Document') |
---|
| 177 | download_name = u'additional_doc' |
---|
| 178 | |
---|
| 179 | class AdditionalDocSlip(AdditionalDocDisplay): |
---|
| 180 | grok.view(ExportPDFClearanceSlip) |
---|
| 181 | |
---|
| 182 | class AdditionalDocUpload(StudentFileUpload): |
---|
| 183 | """Additional Document upload viewlet. |
---|
| 184 | """ |
---|
| 185 | grok.order(19) |
---|
| 186 | title = _(u'Additional Document Scan') |
---|
| 187 | mus = 1024 * 250 |
---|
| 188 | download_name = u'additional_doc' |
---|
| 189 | label = _(u'Additional Document') |
---|
| 190 | |
---|
| 191 | class AdditionalDocImage(StudentImage): |
---|
| 192 | """Renders Additional Document scan. |
---|
| 193 | """ |
---|
| 194 | grok.name('additional_doc') |
---|
| 195 | download_name = u'additional_doc' |
---|