[10765] | 1 | ## $Id: viewlets.py 16154 2020-07-09 03:48:24Z 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 |
---|
[15802] | 20 | from zope.component import getUtility |
---|
[15849] | 21 | from waeup.kofa.interfaces import REQUESTED, IExtFileStore |
---|
[10765] | 22 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
[15802] | 23 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
[15563] | 24 | from kofacustom.iuokada.students.interfaces import ( |
---|
[16087] | 25 | ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent, |
---|
| 26 | ICustomStudentStudyCourse) |
---|
[12430] | 27 | from waeup.kofa.students.fileviewlets import ( |
---|
[12450] | 28 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
[10765] | 29 | from waeup.kofa.students.browser import ( |
---|
[13062] | 30 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
[15802] | 31 | StudyLevelDisplayFormPage, StudentBaseDisplayFormPage) |
---|
[16015] | 32 | from waeup.kofa.students.viewlets import ( |
---|
| 33 | AddPreviousPaymentActionButton, AddBalancePaymentActionButton) |
---|
[10765] | 34 | |
---|
| 35 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
[15650] | 36 | |
---|
[15859] | 37 | class SwitchLibraryAccessActionButton(ManageActionButton): |
---|
| 38 | grok.order(7) |
---|
| 39 | grok.context(ICustomStudent) |
---|
| 40 | grok.view(StudentBaseDisplayFormPage) |
---|
| 41 | grok.require('waeup.switchLibraryAccess') |
---|
| 42 | text = _('Switch library access') |
---|
| 43 | target = 'switch_library_access' |
---|
| 44 | icon = 'actionicon_book.png' |
---|
| 45 | |
---|
[16154] | 46 | class MakePaymentActionButton(ManageActionButton): |
---|
| 47 | grok.order(8) |
---|
| 48 | grok.context(ICustomStudent) |
---|
| 49 | grok.view(StudentBaseDisplayFormPage) |
---|
| 50 | grok.require('waeup.handleStudent') |
---|
| 51 | text = _('Make payment now') |
---|
| 52 | target = 'payments/addop' |
---|
| 53 | icon = 'actionicon_pay.png' |
---|
| 54 | |
---|
[16087] | 55 | class BaseDataSlipActionButton(ManageActionButton): |
---|
| 56 | grok.order(10) |
---|
| 57 | grok.context(ICustomStudentStudyCourse) |
---|
| 58 | grok.view(StudyCourseDisplayFormPage) |
---|
| 59 | grok.require('waeup.viewStudent') |
---|
| 60 | text = _('Download base data slip') |
---|
| 61 | target = 'basedata_slip.pdf' |
---|
| 62 | icon = 'actionicon_pdf.png' |
---|
| 63 | |
---|
[16015] | 64 | class AddBalancePaymentActionButton(AddBalancePaymentActionButton): |
---|
[16031] | 65 | grok.require('waeup.payStudent') |
---|
[15859] | 66 | |
---|
[15802] | 67 | class GetMatricNumberActionButton(ManageActionButton): |
---|
| 68 | grok.order(10) |
---|
| 69 | grok.context(IStudent) |
---|
| 70 | grok.view(StudentBaseDisplayFormPage) |
---|
[15805] | 71 | grok.require('waeup.manageStudent') |
---|
[15802] | 72 | icon = 'actionicon_count.png' |
---|
| 73 | text = _('Get Matriculation Number') |
---|
| 74 | |
---|
| 75 | @property |
---|
| 76 | def target_url(self): |
---|
| 77 | students_utils = getUtility(IStudentsUtils) |
---|
| 78 | if self.context.matric_number: |
---|
| 79 | return '' |
---|
| 80 | error, matric_number = students_utils.constructMatricNumber( |
---|
| 81 | self.context) |
---|
| 82 | if error: |
---|
| 83 | return '' |
---|
| 84 | return self.view.url(self.view.context, 'get_matric_number') |
---|
| 85 | |
---|
[15859] | 86 | # Library |
---|
| 87 | |
---|
| 88 | class LibraryIdCardActionButton(ManageActionButton): |
---|
| 89 | grok.order(10) |
---|
| 90 | grok.context(ICustomStudent) |
---|
| 91 | grok.view(StudentBaseDisplayFormPage) |
---|
| 92 | grok.require('waeup.viewStudent') |
---|
| 93 | icon = 'actionicon_pdf.png' |
---|
| 94 | text = _('Download Library Id Card') |
---|
| 95 | target = 'lib_idcard.pdf' |
---|
| 96 | |
---|
| 97 | @property |
---|
| 98 | def target_url(self): |
---|
| 99 | if self.context.library: |
---|
| 100 | return self.view.url(self.view.context, self.target) |
---|
| 101 | return |
---|
| 102 | |
---|
[15650] | 103 | # Signature |
---|
| 104 | |
---|
| 105 | class SignatureDisplay(StudentFileDisplay): |
---|
| 106 | """Signature display viewlet. |
---|
| 107 | """ |
---|
| 108 | grok.order(2) |
---|
| 109 | label = _(u'Signature') |
---|
| 110 | title = _(u'Signature Scan') |
---|
| 111 | download_name = u'signature' |
---|
| 112 | |
---|
| 113 | class SignatureSlip(SignatureDisplay): |
---|
| 114 | grok.view(ExportPDFClearanceSlip) |
---|
| 115 | |
---|
| 116 | class SignatureUpload(StudentFileUpload): |
---|
| 117 | """Signature upload viewlet. |
---|
| 118 | """ |
---|
| 119 | grok.order(2) |
---|
| 120 | label = _(u'Signature') |
---|
| 121 | title = _(u'Signature Scan') |
---|
| 122 | download_name = u'signature' |
---|
| 123 | |
---|
| 124 | class SignatureImage(StudentImage): |
---|
[15942] | 125 | """Renders signature scan. |
---|
[15650] | 126 | """ |
---|
| 127 | grok.name('signature') |
---|
| 128 | download_name = u'signature' |
---|
| 129 | |
---|
[15849] | 130 | class SignatureDownloadButton(ManageActionButton): |
---|
| 131 | |
---|
| 132 | grok.order(12) |
---|
| 133 | grok.context(IStudent) |
---|
| 134 | grok.view(StudentBaseDisplayFormPage) |
---|
| 135 | grok.require('waeup.manageStudent') |
---|
| 136 | target = 'signature' |
---|
| 137 | text = _('Signature') |
---|
| 138 | icon = 'actionicon_signature.png' |
---|
| 139 | |
---|
| 140 | @property |
---|
| 141 | def target_url(self): |
---|
| 142 | image = getUtility(IExtFileStore).getFileByContext( |
---|
| 143 | self.context, attr='signature') |
---|
| 144 | if not image: |
---|
| 145 | return '' |
---|
| 146 | return self.view.url(self.view.context, self.target) |
---|
| 147 | |
---|
[15654] | 148 | # JAMB Result |
---|
| 149 | |
---|
| 150 | class JAMBResultDisplay(StudentFileDisplay): |
---|
| 151 | """JAMB Result display viewlet. |
---|
| 152 | """ |
---|
| 153 | grok.order(9) |
---|
| 154 | label = _(u'JAMB Result') |
---|
| 155 | title = _(u'JAMB Result') |
---|
| 156 | download_name = u'jamb' |
---|
| 157 | |
---|
| 158 | class JAMBResultSlip(JAMBResultDisplay): |
---|
| 159 | grok.view(ExportPDFClearanceSlip) |
---|
| 160 | |
---|
| 161 | class JAMBResultUpload(StudentFileUpload): |
---|
| 162 | """JAMB Result upload viewlet. |
---|
| 163 | """ |
---|
| 164 | grok.order(9) |
---|
| 165 | label = _(u'JAMB Result') |
---|
| 166 | title = _(u'JAMB Result Scan') |
---|
| 167 | download_name = u'jamb' |
---|
| 168 | |
---|
| 169 | class JAMBResultImage(StudentImage): |
---|
| 170 | """Renders JAMB Result scan. |
---|
| 171 | """ |
---|
| 172 | grok.name('jamb') |
---|
| 173 | download_name = u'jamb' |
---|
| 174 | |
---|