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