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