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