[9382] | 1 | ## $Id: viewlets.py 14902 2017-11-17 16:12:06Z 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 |
---|
[12855] | 20 | from waeup.kofa.interfaces import REQUESTED, REGISTERED |
---|
[9439] | 21 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
[9848] | 22 | from waeup.uniben.students.interfaces import ( |
---|
[12121] | 23 | ICustomStudentStudyCourse, ICustomStudentStudyLevel, |
---|
| 24 | ICustomStudent, ) |
---|
[12423] | 25 | from waeup.kofa.students.fileviewlets import ( |
---|
[13723] | 26 | StudentFileDisplay, StudentFileUpload, StudentImage,) |
---|
[9439] | 27 | from waeup.kofa.students.browser import ( |
---|
[13063] | 28 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
[13723] | 29 | StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage, |
---|
| 30 | StudentBaseDisplayFormPage) |
---|
[9382] | 31 | |
---|
| 32 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
| 33 | |
---|
[9439] | 34 | class StudyCourseEditActionButton(ManageActionButton): |
---|
| 35 | grok.order(1) |
---|
| 36 | grok.context(ICustomStudentStudyCourse) |
---|
| 37 | grok.view(StudyCourseDisplayFormPage) |
---|
| 38 | grok.require('waeup.clearStudent') |
---|
| 39 | text = _('Edit level') |
---|
| 40 | target = 'edit_level' |
---|
[9382] | 41 | |
---|
[9439] | 42 | @property |
---|
| 43 | def target_url(self): |
---|
| 44 | if self.context.is_current and self.context.student.state == REQUESTED: |
---|
| 45 | return self.view.url(self.view.context, self.target) |
---|
| 46 | return False |
---|
| 47 | |
---|
[12855] | 48 | class CourseRegistrationSlipActionButton(ManageActionButton): |
---|
| 49 | grok.order(5) |
---|
| 50 | grok.context(ICustomStudentStudyLevel) |
---|
| 51 | grok.view(StudyLevelDisplayFormPage) |
---|
| 52 | grok.require('waeup.viewStudent') |
---|
| 53 | icon = 'actionicon_pdf.png' |
---|
| 54 | text = _('Download course registration slip') |
---|
| 55 | target = 'course_registration_slip.pdf' |
---|
| 56 | |
---|
| 57 | @property |
---|
| 58 | def target_url(self): |
---|
| 59 | is_current = self.context.__parent__.is_current |
---|
| 60 | if not is_current: |
---|
| 61 | return '' |
---|
| 62 | if self.context.student.state != REGISTERED \ |
---|
| 63 | or self.context.student.current_level != self.context.level: |
---|
| 64 | return '' |
---|
| 65 | return self.view.url(self.view.context, self.target) |
---|
| 66 | |
---|
[9848] | 67 | class CourseResultSlipActionButton(ManageActionButton): |
---|
| 68 | grok.order(6) |
---|
| 69 | grok.context(ICustomStudentStudyLevel) |
---|
| 70 | grok.view(StudyLevelDisplayFormPage) |
---|
| 71 | grok.require('waeup.viewStudent') |
---|
| 72 | icon = 'actionicon_pdf.png' |
---|
| 73 | text = _('Download course result slip') |
---|
| 74 | target = 'course_result_slip.pdf' |
---|
| 75 | |
---|
| 76 | @property |
---|
| 77 | def target_url(self): |
---|
| 78 | return self.view.url(self.view.context, self.target) |
---|
| 79 | |
---|
[12121] | 80 | |
---|
| 81 | class ClearanceInvitationSlipActionButton(ManageActionButton): |
---|
| 82 | grok.order(5) |
---|
| 83 | grok.context(ICustomStudent) |
---|
| 84 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 85 | grok.require('waeup.viewStudent') |
---|
| 86 | icon = 'actionicon_pdf.png' |
---|
| 87 | text = _('Download clearance invitation slip') |
---|
| 88 | target = 'clearance_invitation_slip.pdf' |
---|
| 89 | |
---|
[12122] | 90 | @property |
---|
| 91 | def target_url(self): |
---|
| 92 | if self.context.student.state == REQUESTED \ |
---|
| 93 | and self.context.student.physical_clearance_date: |
---|
| 94 | return self.view.url(self.view.context, self.target) |
---|
| 95 | return False |
---|
[12121] | 96 | |
---|
[13723] | 97 | class ExaminationScheduleSlipActionButton(ManageActionButton): |
---|
| 98 | grok.order(10) |
---|
| 99 | grok.context(ICustomStudent) |
---|
| 100 | grok.view(StudentBaseDisplayFormPage) |
---|
| 101 | grok.require('waeup.viewStudent') |
---|
| 102 | icon = 'actionicon_pdf.png' |
---|
| 103 | text = _('Download examination schedule slip') |
---|
| 104 | target = 'examination_schedule_slip.pdf' |
---|
[12122] | 105 | |
---|
[13723] | 106 | @property |
---|
| 107 | def target_url(self): |
---|
| 108 | if self.context.flash_notice \ |
---|
| 109 | and 'exam' in self.context.flash_notice.lower(): |
---|
| 110 | return self.view.url(self.view.context, self.target) |
---|
| 111 | return False |
---|
| 112 | |
---|
[14834] | 113 | class JUPEBResultSlipActionButton(ManageActionButton): |
---|
| 114 | grok.order(11) |
---|
| 115 | grok.context(ICustomStudent) |
---|
| 116 | grok.view(StudentBaseDisplayFormPage) |
---|
| 117 | grok.require('waeup.viewStudent') |
---|
| 118 | icon = 'actionicon_pdf.png' |
---|
| 119 | text = _('Download JUPEB result slip') |
---|
| 120 | target = 'jupeb_result_slip.pdf' |
---|
| 121 | |
---|
| 122 | @property |
---|
| 123 | def target_url(self): |
---|
[14902] | 124 | if self.context.flash_notice and self.context.is_jupeb \ |
---|
[14835] | 125 | and 'results' in self.context.flash_notice.lower(): |
---|
[14834] | 126 | return self.view.url(self.view.context, self.target) |
---|
| 127 | return False |
---|
| 128 | |
---|
[9382] | 129 | # JAMB Letter |
---|
| 130 | |
---|
[12452] | 131 | class JAMBLetterDisplay(StudentFileDisplay): |
---|
[9382] | 132 | """JAMB Letter display viewlet. |
---|
| 133 | """ |
---|
| 134 | grok.order(19) |
---|
| 135 | label = _(u'JAMB Letter') |
---|
| 136 | title = _(u'JAMB Letter') |
---|
[11556] | 137 | download_name = u'jamb_letter' |
---|
[9382] | 138 | |
---|
| 139 | class JAMBLetterSlip(JAMBLetterDisplay): |
---|
[13063] | 140 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 141 | |
---|
[12452] | 142 | class JAMBLetterUpload(StudentFileUpload): |
---|
[9382] | 143 | """JAMB Letter upload viewlet. |
---|
| 144 | """ |
---|
| 145 | grok.order(19) |
---|
| 146 | label = _(u'JAMB Letter') |
---|
| 147 | title = _(u'JAMB Letter Scan') |
---|
| 148 | mus = 1024 * 150 |
---|
[11556] | 149 | download_name = u'jamb_letter' |
---|
[9382] | 150 | |
---|
[12452] | 151 | class JAMBLetterImage(StudentImage): |
---|
[9382] | 152 | """Renders JAMB Letter scan. |
---|
| 153 | """ |
---|
[11556] | 154 | grok.name('jamb_letter') |
---|
| 155 | download_name = u'jamb_letter' |
---|
[9382] | 156 | |
---|
| 157 | # Affidavit of Non-Membership of Secret Cults |
---|
| 158 | |
---|
[12452] | 159 | class SecrCultsStatementDisplay(StudentFileDisplay): |
---|
[9382] | 160 | """Affidavit of Non-Membership of Secret Cults display viewlet. |
---|
| 161 | """ |
---|
| 162 | grok.order(20) |
---|
| 163 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 164 | title = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 165 | download_name = u'secr_cults' |
---|
| 166 | |
---|
| 167 | class SecrCultsStatementSlip(SecrCultsStatementDisplay): |
---|
[13063] | 168 | grok.view(ExportPDFClearanceSlip) |
---|
[9382] | 169 | |
---|
[12452] | 170 | class SecrCultsStatementUpload(StudentFileUpload): |
---|
[9382] | 171 | """Affidavit of Non-Membership of Secret Cults upload viewlet. |
---|
| 172 | """ |
---|
| 173 | grok.order(20) |
---|
| 174 | label = _(u'Affidavit of Non-Membership of Secret Cults') |
---|
| 175 | title = _(u'Affidavit of Non-Membership of Secret Cults Scan') |
---|
| 176 | mus = 1024 * 150 |
---|
| 177 | download_name = u'secr_cults' |
---|
| 178 | |
---|
[12452] | 179 | class SecrCultsStatementImage(StudentImage): |
---|
[9382] | 180 | """Renders Affidavit of Non-Membership of Secret Cults scan. |
---|
| 181 | """ |
---|
| 182 | grok.name('secr_cults') |
---|
[11611] | 183 | download_name = u'secr_cults' |
---|
| 184 | |
---|
| 185 | # Fingerprints |
---|
| 186 | |
---|
[12452] | 187 | class LeftThumbPrintDisplay(StudentFileDisplay): |
---|
[11611] | 188 | """Left thumb fingerprint display viewlet. |
---|
| 189 | """ |
---|
| 190 | grok.order(21) |
---|
| 191 | label = _(u'Left Thumb Fingerprint') |
---|
| 192 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
| 193 | download_name = u'finger1.fpm' |
---|
| 194 | |
---|
| 195 | class LeftThumbPrintSlip(LeftThumbPrintDisplay): |
---|
| 196 | """Mentions scanned fingerprint on slip. |
---|
| 197 | |
---|
| 198 | Fingerprint minutiae is not printet. |
---|
| 199 | """ |
---|
[13063] | 200 | grok.view(ExportPDFClearanceSlip) |
---|
[11611] | 201 | |
---|
[12452] | 202 | class LeftThumbPrintUpload(StudentFileUpload): |
---|
[11611] | 203 | """Left thumb fingerprint upload viewlet. |
---|
| 204 | """ |
---|
| 205 | grok.order(21) |
---|
[11613] | 206 | grok.require('waeup.manageStudent') |
---|
[11611] | 207 | label = _(u'Left Thumb Fingerprint') |
---|
| 208 | title = _(u'Left Thumb Fingerprint Minutiae') |
---|
| 209 | mus = 1024 * 5 |
---|
| 210 | download_name = u'finger1.fpm' |
---|
| 211 | |
---|
[12452] | 212 | class LeftThumbPrintImage(StudentImage): |
---|
[11611] | 213 | """Renders left thumb fingerprint minutiae for download. |
---|
| 214 | """ |
---|
| 215 | grok.name('finger1.fpm') |
---|
| 216 | download_name = u'finger1.fpm' |
---|