[9382] | 1 | ## $Id: viewlets.py 17822 2024-06-27 07:47:23Z 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 ( |
---|
[17812] | 31 | RequestTranscriptActionButton, |
---|
[16906] | 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 | |
---|
[17822] | 239 | class NYSCEditActionButton(ManageActionButton): |
---|
| 240 | grok.order(13) |
---|
| 241 | grok.context(ICustomStudent) |
---|
| 242 | grok.view(StudentBaseDisplayFormPage) |
---|
| 243 | grok.require('waeup.handleStudent') |
---|
| 244 | text = _('NYSC Request') |
---|
| 245 | target = 'edit_nysc' |
---|
| 246 | icon = 'actionicon_nigeria.png' |
---|
| 247 | |
---|
| 248 | @property |
---|
| 249 | def target_url(self): |
---|
| 250 | if not self.context.eligible_for_nysc: |
---|
| 251 | return '' |
---|
| 252 | return self.view.url(self.view.context, self.target) |
---|
| 253 | |
---|
| 254 | class NYSCManageActionButton(ManageActionButton): |
---|
| 255 | grok.require('waeup.manageStudent') |
---|
| 256 | text = _('Manage NYSC request data') |
---|
| 257 | target = 'manage_nysc' |
---|
| 258 | grok.order(13) |
---|
| 259 | grok.context(ICustomStudent) |
---|
| 260 | grok.view(StudentBaseDisplayFormPage) |
---|
| 261 | icon = 'actionicon_nigeria.png' |
---|
| 262 | |
---|
[9382] | 263 | # JAMB Letter |
---|
| 264 | |
---|
[12452] | 265 | class JAMBLetterDisplay(StudentFileDisplay): |
---|
[9382] | 266 | """JAMB Letter display viewlet. |
---|
| 267 | """ |
---|
| 268 | grok.order(19) |
---|
| 269 | label = _(u'JAMB Letter') |
---|
| 270 | title = _(u'JAMB Letter') |
---|
[11556] | 271 | download_name = u'jamb_letter' |
---|
[9382] | 272 | |
---|
| 273 | class JAMBLetterSlip(JAMBLetterDisplay): |
---|
[13063] | 274 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 275 | |
---|
[12452] | 276 | class JAMBLetterUpload(StudentFileUpload): |
---|
[9382] | 277 | """JAMB Letter upload viewlet. |
---|
| 278 | """ |
---|
| 279 | grok.order(19) |
---|
| 280 | label = _(u'JAMB Letter') |
---|
| 281 | title = _(u'JAMB Letter Scan') |
---|
| 282 | mus = 1024 * 150 |
---|
[11556] | 283 | download_name = u'jamb_letter' |
---|
[9382] | 284 | |
---|
[12452] | 285 | class JAMBLetterImage(StudentImage): |
---|
[9382] | 286 | """Renders JAMB Letter scan. |
---|
| 287 | """ |
---|
[11556] | 288 | grok.name('jamb_letter') |
---|
| 289 | download_name = u'jamb_letter' |
---|
[9382] | 290 | |
---|
| 291 | # Affidavit of Non-Membership of Secret Cults |
---|
| 292 | |
---|
[12452] | 293 | class SecrCultsStatementDisplay(StudentFileDisplay): |
---|
[9382] | 294 | """Affidavit of Non-Membership of Secret Cults display viewlet. |
---|
| 295 | """ |
---|
| 296 | grok.order(20) |
---|
| 297 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 298 | title = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 299 | download_name = u'secr_cults' |
---|
| 300 | |
---|
| 301 | class SecrCultsStatementSlip(SecrCultsStatementDisplay): |
---|
[13063] | 302 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 303 | |
---|
[12452] | 304 | class SecrCultsStatementUpload(StudentFileUpload): |
---|
[9382] | 305 | """Affidavit of Non-Membership of Secret Cults upload viewlet. |
---|
| 306 | """ |
---|
| 307 | grok.order(20) |
---|
| 308 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 309 | title = _(u'Affidavit of Non-Membership of Secret Cults Scan') |
---|
| 310 | mus = 1024 * 150 |
---|
| 311 | download_name = u'secr_cults' |
---|
| 312 | |
---|
[12452] | 313 | class SecrCultsStatementImage(StudentImage): |
---|
[9382] | 314 | """Renders Affidavit of Non-Membership of Secret Cults scan. |
---|
| 315 | """ |
---|
| 316 | grok.name('secr_cults') |
---|
[11611] | 317 | download_name = u'secr_cults' |
---|
| 318 | |
---|
[16364] | 319 | # O Level Results Scratch Card |
---|
[16359] | 320 | |
---|
[16364] | 321 | class OLevelResultsScratchCardDisplay(StudentFileDisplay): |
---|
| 322 | """O'Level Results Scratch Card display viewlet. |
---|
[16359] | 323 | """ |
---|
| 324 | grok.order(20) |
---|
[16364] | 325 | label = _(u'O Level Results Scratch Card') |
---|
| 326 | title = _(u'O Level Results Scratch Card') |
---|
| 327 | download_name = u'olevel_sc' |
---|
[16359] | 328 | |
---|
[16364] | 329 | class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay): |
---|
[16359] | 330 | grok.view(ExportPDFClearanceSlip) |
---|
| 331 | |
---|
[16364] | 332 | class OLevelResultsScratchCardUpload(StudentFileUpload): |
---|
| 333 | """O Level Results Scratch Card upload viewlet. |
---|
[16359] | 334 | """ |
---|
| 335 | grok.order(20) |
---|
[16364] | 336 | label = _(u'O Level Results Scratch Card') |
---|
| 337 | title = _(u'O Level Results Scratch Card Scan') |
---|
[16359] | 338 | mus = 1024 * 150 |
---|
[16364] | 339 | download_name = u'olevel_sc' |
---|
[16359] | 340 | |
---|
[16364] | 341 | class OLevelResultsScratchCardImage(StudentImage): |
---|
| 342 | """Renders O Level Results Scratch Card scan. |
---|
[16359] | 343 | """ |
---|
[16364] | 344 | grok.name('olevel_sc') |
---|
| 345 | download_name = u'olevel_sc' |
---|
[16359] | 346 | |
---|
[11611] | 347 | # Fingerprints |
---|
| 348 | |
---|
[12452] | 349 | class LeftThumbPrintDisplay(StudentFileDisplay): |
---|
[11611] | 350 | """Left thumb fingerprint display viewlet. |
---|
| 351 | """ |
---|
| 352 | grok.order(21) |
---|
| 353 | label = _(u'Left Thumb Fingerprint') |
---|
| 354 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
| 355 | download_name = u'finger1.fpm' |
---|
| 356 | |
---|
| 357 | class LeftThumbPrintSlip(LeftThumbPrintDisplay): |
---|
| 358 | """Mentions scanned fingerprint on slip. |
---|
[16443] | 359 | Fingerprint minutiae is not printed. |
---|
[11611] | 360 | """ |
---|
[13063] | 361 | grok.view(ExportPDFClearanceSlip) |
---|
[11611] | 362 | |
---|
[12452] | 363 | class LeftThumbPrintUpload(StudentFileUpload): |
---|
[11611] | 364 | """Left thumb fingerprint upload viewlet. |
---|
| 365 | """ |
---|
| 366 | grok.order(21) |
---|
[11613] | 367 | grok.require('waeup.manageStudent') |
---|
[11611] | 368 | label = _(u'Left Thumb Fingerprint') |
---|
| 369 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
[16363] | 370 | mus = 1024 * 150 |
---|
[11611] | 371 | download_name = u'finger1.fpm' |
---|
| 372 | |
---|
[12452] | 373 | class LeftThumbPrintImage(StudentImage): |
---|
[11611] | 374 | """Renders left thumb fingerprint minutiae for download. |
---|
| 375 | """ |
---|
| 376 | grok.name('finger1.fpm') |
---|
[16423] | 377 | download_name = u'finger1.fpm' |
---|
| 378 | |
---|
[16473] | 379 | # Original JAMB picture |
---|
[16423] | 380 | |
---|
[16441] | 381 | class JAMBPictureDisplay(PassportDisplay): |
---|
[16423] | 382 | """Original JAMB picture display viewlet. |
---|
| 383 | """ |
---|
[16473] | 384 | grok.order(22) |
---|
[16423] | 385 | label = _(u'Original JAMB Picture') |
---|
| 386 | title = _(u'Original JAMB Picture') |
---|
[16443] | 387 | download_name = u'passport2' |
---|
[16423] | 388 | |
---|
| 389 | class JAMBPictureSlip(JAMBPictureDisplay): |
---|
| 390 | grok.view(ExportPDFClearanceSlip) |
---|
| 391 | |
---|
[16473] | 392 | class JAMBPictureUpload(StudentFileUpload): |
---|
| 393 | """Original JAMB picture upload viewlet. |
---|
| 394 | """ |
---|
| 395 | grok.order(22) |
---|
| 396 | grok.require('waeup.manageStudent') |
---|
| 397 | label = _(u'Original JAMB Picture') |
---|
| 398 | title = _(u'Original JAMB Picture') |
---|
| 399 | mus = 1024 * 150 |
---|
| 400 | download_name = u'passport2' |
---|
| 401 | |
---|
[16423] | 402 | class JAMBPictureImage(StudentImage): |
---|
| 403 | """Renders Original JAMB picture. |
---|
| 404 | """ |
---|
[16443] | 405 | grok.name('passport2') |
---|
| 406 | download_name = u'passport2' |
---|