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