[9382] | 1 | ## $Id: viewlets.py 16364 2021-01-11 14:48:41Z 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 |
---|
[16361] | 20 | from zope.component import getUtility |
---|
| 21 | from waeup.kofa.interfaces import REQUESTED, REGISTERED, IExtFileStore |
---|
[9439] | 22 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
[16361] | 23 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[12423] | 24 | from waeup.kofa.students.fileviewlets import ( |
---|
[13723] | 25 | StudentFileDisplay, StudentFileUpload, StudentImage,) |
---|
[9439] | 26 | from waeup.kofa.students.browser import ( |
---|
[13063] | 27 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
[13723] | 28 | StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage, |
---|
| 29 | StudentBaseDisplayFormPage) |
---|
[16361] | 30 | from waeup.kofa.students.viewlets import ( |
---|
| 31 | RequestTranscriptActionButton, StudentPassportActionButton) |
---|
[9382] | 32 | |
---|
[16361] | 33 | from waeup.uniben.students.interfaces import ( |
---|
| 34 | ICustomStudentStudyCourse, ICustomStudentStudyLevel, |
---|
[16362] | 35 | ICustomStudent,) |
---|
[16361] | 36 | |
---|
[9382] | 37 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
| 38 | |
---|
[16130] | 39 | class CustomRequestTranscriptActionButton(RequestTranscriptActionButton): |
---|
| 40 | |
---|
| 41 | @property |
---|
| 42 | def target_url(self): |
---|
| 43 | return '' |
---|
| 44 | |
---|
[16361] | 45 | class CustomStudentPassportActionButton(StudentPassportActionButton): |
---|
| 46 | |
---|
| 47 | @property |
---|
| 48 | def target_url(self): |
---|
[16362] | 49 | # Uniben: Only 2020 session students are allowed to edit the picture. |
---|
| 50 | if self.context.entry_session != 2020: |
---|
| 51 | return '' |
---|
[16361] | 52 | # Passport pictures must not be editable if application slip |
---|
| 53 | # exists. |
---|
| 54 | slip = getUtility(IExtFileStore).getFileByContext( |
---|
| 55 | self.context, 'application_slip') |
---|
| 56 | PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES |
---|
| 57 | if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None: |
---|
| 58 | return '' |
---|
| 59 | return self.view.url(self.view.context, self.target) |
---|
| 60 | |
---|
[15371] | 61 | class SwitchLibraryAccessActionButton(ManageActionButton): |
---|
| 62 | grok.order(7) |
---|
| 63 | grok.context(ICustomStudent) |
---|
| 64 | grok.view(StudentBaseDisplayFormPage) |
---|
| 65 | grok.require('waeup.switchLibraryAccess') |
---|
| 66 | text = _('Switch library access') |
---|
| 67 | target = 'switch_library_access' |
---|
| 68 | icon = 'actionicon_book.png' |
---|
| 69 | |
---|
[9439] | 70 | class StudyCourseEditActionButton(ManageActionButton): |
---|
| 71 | grok.order(1) |
---|
| 72 | grok.context(ICustomStudentStudyCourse) |
---|
| 73 | grok.view(StudyCourseDisplayFormPage) |
---|
| 74 | grok.require('waeup.clearStudent') |
---|
| 75 | text = _('Edit level') |
---|
| 76 | target = 'edit_level' |
---|
[9382] | 77 | |
---|
[9439] | 78 | @property |
---|
| 79 | def target_url(self): |
---|
| 80 | if self.context.is_current and self.context.student.state == REQUESTED: |
---|
| 81 | return self.view.url(self.view.context, self.target) |
---|
| 82 | return False |
---|
| 83 | |
---|
[12855] | 84 | class CourseRegistrationSlipActionButton(ManageActionButton): |
---|
| 85 | grok.order(5) |
---|
| 86 | grok.context(ICustomStudentStudyLevel) |
---|
| 87 | grok.view(StudyLevelDisplayFormPage) |
---|
| 88 | grok.require('waeup.viewStudent') |
---|
| 89 | icon = 'actionicon_pdf.png' |
---|
| 90 | text = _('Download course registration slip') |
---|
| 91 | target = 'course_registration_slip.pdf' |
---|
| 92 | |
---|
| 93 | @property |
---|
| 94 | def target_url(self): |
---|
| 95 | is_current = self.context.__parent__.is_current |
---|
| 96 | if not is_current: |
---|
| 97 | return '' |
---|
| 98 | if self.context.student.state != REGISTERED \ |
---|
| 99 | or self.context.student.current_level != self.context.level: |
---|
| 100 | return '' |
---|
| 101 | return self.view.url(self.view.context, self.target) |
---|
| 102 | |
---|
[9848] | 103 | class CourseResultSlipActionButton(ManageActionButton): |
---|
| 104 | grok.order(6) |
---|
| 105 | grok.context(ICustomStudentStudyLevel) |
---|
| 106 | grok.view(StudyLevelDisplayFormPage) |
---|
| 107 | grok.require('waeup.viewStudent') |
---|
| 108 | icon = 'actionicon_pdf.png' |
---|
| 109 | text = _('Download course result slip') |
---|
| 110 | target = 'course_result_slip.pdf' |
---|
| 111 | |
---|
| 112 | @property |
---|
| 113 | def target_url(self): |
---|
| 114 | return self.view.url(self.view.context, self.target) |
---|
| 115 | |
---|
[12121] | 116 | |
---|
| 117 | class ClearanceInvitationSlipActionButton(ManageActionButton): |
---|
| 118 | grok.order(5) |
---|
| 119 | grok.context(ICustomStudent) |
---|
| 120 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 121 | grok.require('waeup.viewStudent') |
---|
| 122 | icon = 'actionicon_pdf.png' |
---|
| 123 | text = _('Download clearance invitation slip') |
---|
| 124 | target = 'clearance_invitation_slip.pdf' |
---|
| 125 | |
---|
[12122] | 126 | @property |
---|
| 127 | def target_url(self): |
---|
| 128 | if self.context.student.state == REQUESTED \ |
---|
| 129 | and self.context.student.physical_clearance_date: |
---|
| 130 | return self.view.url(self.view.context, self.target) |
---|
| 131 | return False |
---|
[12121] | 132 | |
---|
[13723] | 133 | class ExaminationScheduleSlipActionButton(ManageActionButton): |
---|
| 134 | grok.order(10) |
---|
| 135 | grok.context(ICustomStudent) |
---|
| 136 | grok.view(StudentBaseDisplayFormPage) |
---|
| 137 | grok.require('waeup.viewStudent') |
---|
| 138 | icon = 'actionicon_pdf.png' |
---|
| 139 | text = _('Download examination schedule slip') |
---|
| 140 | target = 'examination_schedule_slip.pdf' |
---|
[12122] | 141 | |
---|
[13723] | 142 | @property |
---|
| 143 | def target_url(self): |
---|
| 144 | if self.context.flash_notice \ |
---|
| 145 | and 'exam' in self.context.flash_notice.lower(): |
---|
| 146 | return self.view.url(self.view.context, self.target) |
---|
| 147 | return False |
---|
| 148 | |
---|
[15352] | 149 | class JHLIdCardActionButton(ManageActionButton): |
---|
| 150 | grok.order(10) |
---|
| 151 | grok.context(ICustomStudent) |
---|
| 152 | grok.view(StudentBaseDisplayFormPage) |
---|
| 153 | grok.require('waeup.viewStudent') |
---|
| 154 | icon = 'actionicon_pdf.png' |
---|
| 155 | text = _('Download JHL Id Card') |
---|
| 156 | target = 'jhl_idcard.pdf' |
---|
| 157 | |
---|
| 158 | @property |
---|
| 159 | def target_url(self): |
---|
[15371] | 160 | if self.context.library: |
---|
| 161 | return self.view.url(self.view.context, self.target) |
---|
| 162 | return |
---|
[15352] | 163 | |
---|
[14834] | 164 | class JUPEBResultSlipActionButton(ManageActionButton): |
---|
| 165 | grok.order(11) |
---|
| 166 | grok.context(ICustomStudent) |
---|
| 167 | grok.view(StudentBaseDisplayFormPage) |
---|
| 168 | grok.require('waeup.viewStudent') |
---|
| 169 | icon = 'actionicon_pdf.png' |
---|
| 170 | text = _('Download JUPEB result slip') |
---|
| 171 | target = 'jupeb_result_slip.pdf' |
---|
| 172 | |
---|
| 173 | @property |
---|
| 174 | def target_url(self): |
---|
[14902] | 175 | if self.context.flash_notice and self.context.is_jupeb \ |
---|
[14835] | 176 | and 'results' in self.context.flash_notice.lower(): |
---|
[14834] | 177 | return self.view.url(self.view.context, self.target) |
---|
| 178 | return False |
---|
| 179 | |
---|
[9382] | 180 | # JAMB Letter |
---|
| 181 | |
---|
[12452] | 182 | class JAMBLetterDisplay(StudentFileDisplay): |
---|
[9382] | 183 | """JAMB Letter display viewlet. |
---|
| 184 | """ |
---|
| 185 | grok.order(19) |
---|
| 186 | label = _(u'JAMB Letter') |
---|
| 187 | title = _(u'JAMB Letter') |
---|
[11556] | 188 | download_name = u'jamb_letter' |
---|
[9382] | 189 | |
---|
| 190 | class JAMBLetterSlip(JAMBLetterDisplay): |
---|
[13063] | 191 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 192 | |
---|
[12452] | 193 | class JAMBLetterUpload(StudentFileUpload): |
---|
[9382] | 194 | """JAMB Letter upload viewlet. |
---|
| 195 | """ |
---|
| 196 | grok.order(19) |
---|
| 197 | label = _(u'JAMB Letter') |
---|
| 198 | title = _(u'JAMB Letter Scan') |
---|
| 199 | mus = 1024 * 150 |
---|
[11556] | 200 | download_name = u'jamb_letter' |
---|
[9382] | 201 | |
---|
[12452] | 202 | class JAMBLetterImage(StudentImage): |
---|
[9382] | 203 | """Renders JAMB Letter scan. |
---|
| 204 | """ |
---|
[11556] | 205 | grok.name('jamb_letter') |
---|
| 206 | download_name = u'jamb_letter' |
---|
[9382] | 207 | |
---|
| 208 | # Affidavit of Non-Membership of Secret Cults |
---|
| 209 | |
---|
[12452] | 210 | class SecrCultsStatementDisplay(StudentFileDisplay): |
---|
[9382] | 211 | """Affidavit of Non-Membership of Secret Cults display viewlet. |
---|
| 212 | """ |
---|
| 213 | grok.order(20) |
---|
| 214 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 215 | title = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 216 | download_name = u'secr_cults' |
---|
| 217 | |
---|
| 218 | class SecrCultsStatementSlip(SecrCultsStatementDisplay): |
---|
[13063] | 219 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 220 | |
---|
[12452] | 221 | class SecrCultsStatementUpload(StudentFileUpload): |
---|
[9382] | 222 | """Affidavit of Non-Membership of Secret Cults upload viewlet. |
---|
| 223 | """ |
---|
| 224 | grok.order(20) |
---|
| 225 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 226 | title = _(u'Affidavit of Non-Membership of Secret Cults Scan') |
---|
| 227 | mus = 1024 * 150 |
---|
| 228 | download_name = u'secr_cults' |
---|
| 229 | |
---|
[12452] | 230 | class SecrCultsStatementImage(StudentImage): |
---|
[9382] | 231 | """Renders Affidavit of Non-Membership of Secret Cults scan. |
---|
| 232 | """ |
---|
| 233 | grok.name('secr_cults') |
---|
[11611] | 234 | download_name = u'secr_cults' |
---|
| 235 | |
---|
[16364] | 236 | # O Level Results Scratch Card |
---|
[16359] | 237 | |
---|
[16364] | 238 | class OLevelResultsScratchCardDisplay(StudentFileDisplay): |
---|
| 239 | """O'Level Results Scratch Card display viewlet. |
---|
[16359] | 240 | """ |
---|
| 241 | grok.order(20) |
---|
[16364] | 242 | label = _(u'O Level Results Scratch Card') |
---|
| 243 | title = _(u'O Level Results Scratch Card') |
---|
| 244 | download_name = u'olevel_sc' |
---|
[16359] | 245 | |
---|
[16364] | 246 | class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay): |
---|
[16359] | 247 | grok.view(ExportPDFClearanceSlip) |
---|
| 248 | |
---|
[16364] | 249 | class OLevelResultsScratchCardUpload(StudentFileUpload): |
---|
| 250 | """O Level Results Scratch Card upload viewlet. |
---|
[16359] | 251 | """ |
---|
| 252 | grok.order(20) |
---|
[16364] | 253 | label = _(u'O Level Results Scratch Card') |
---|
| 254 | title = _(u'O Level Results Scratch Card Scan') |
---|
[16359] | 255 | mus = 1024 * 150 |
---|
[16364] | 256 | download_name = u'olevel_sc' |
---|
[16359] | 257 | |
---|
[16364] | 258 | class OLevelResultsScratchCardImage(StudentImage): |
---|
| 259 | """Renders O Level Results Scratch Card scan. |
---|
[16359] | 260 | """ |
---|
[16364] | 261 | grok.name('olevel_sc') |
---|
| 262 | download_name = u'olevel_sc' |
---|
[16359] | 263 | |
---|
[11611] | 264 | # Fingerprints |
---|
| 265 | |
---|
[12452] | 266 | class LeftThumbPrintDisplay(StudentFileDisplay): |
---|
[11611] | 267 | """Left thumb fingerprint display viewlet. |
---|
| 268 | """ |
---|
| 269 | grok.order(21) |
---|
| 270 | label = _(u'Left Thumb Fingerprint') |
---|
| 271 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
| 272 | download_name = u'finger1.fpm' |
---|
| 273 | |
---|
| 274 | class LeftThumbPrintSlip(LeftThumbPrintDisplay): |
---|
| 275 | """Mentions scanned fingerprint on slip. |
---|
| 276 | |
---|
| 277 | Fingerprint minutiae is not printet. |
---|
| 278 | """ |
---|
[13063] | 279 | grok.view(ExportPDFClearanceSlip) |
---|
[11611] | 280 | |
---|
[12452] | 281 | class LeftThumbPrintUpload(StudentFileUpload): |
---|
[11611] | 282 | """Left thumb fingerprint upload viewlet. |
---|
| 283 | """ |
---|
| 284 | grok.order(21) |
---|
[11613] | 285 | grok.require('waeup.manageStudent') |
---|
[11611] | 286 | label = _(u'Left Thumb Fingerprint') |
---|
| 287 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
[16363] | 288 | mus = 1024 * 150 |
---|
[11611] | 289 | download_name = u'finger1.fpm' |
---|
| 290 | |
---|
[12452] | 291 | class LeftThumbPrintImage(StudentImage): |
---|
[11611] | 292 | """Renders left thumb fingerprint minutiae for download. |
---|
| 293 | """ |
---|
| 294 | grok.name('finger1.fpm') |
---|
| 295 | download_name = u'finger1.fpm' |
---|