[10765] | 1 | ## $Id: viewlets.py 16087 2020-05-06 13:49:45Z 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 | |
---|
[16087] | 46 | class BaseDataSlipActionButton(ManageActionButton): |
---|
| 47 | grok.order(10) |
---|
| 48 | grok.context(ICustomStudentStudyCourse) |
---|
| 49 | grok.view(StudyCourseDisplayFormPage) |
---|
| 50 | grok.require('waeup.viewStudent') |
---|
| 51 | text = _('Download base data slip') |
---|
| 52 | target = 'basedata_slip.pdf' |
---|
| 53 | icon = 'actionicon_pdf.png' |
---|
| 54 | |
---|
[16015] | 55 | class AddBalancePaymentActionButton(AddBalancePaymentActionButton): |
---|
[16031] | 56 | grok.require('waeup.payStudent') |
---|
[15859] | 57 | |
---|
[15802] | 58 | class GetMatricNumberActionButton(ManageActionButton): |
---|
| 59 | grok.order(10) |
---|
| 60 | grok.context(IStudent) |
---|
| 61 | grok.view(StudentBaseDisplayFormPage) |
---|
[15805] | 62 | grok.require('waeup.manageStudent') |
---|
[15802] | 63 | icon = 'actionicon_count.png' |
---|
| 64 | text = _('Get Matriculation Number') |
---|
| 65 | |
---|
| 66 | @property |
---|
| 67 | def target_url(self): |
---|
| 68 | students_utils = getUtility(IStudentsUtils) |
---|
| 69 | if self.context.matric_number: |
---|
| 70 | return '' |
---|
| 71 | error, matric_number = students_utils.constructMatricNumber( |
---|
| 72 | self.context) |
---|
| 73 | if error: |
---|
| 74 | return '' |
---|
| 75 | return self.view.url(self.view.context, 'get_matric_number') |
---|
| 76 | |
---|
[15859] | 77 | # Library |
---|
| 78 | |
---|
| 79 | class LibraryIdCardActionButton(ManageActionButton): |
---|
| 80 | grok.order(10) |
---|
| 81 | grok.context(ICustomStudent) |
---|
| 82 | grok.view(StudentBaseDisplayFormPage) |
---|
| 83 | grok.require('waeup.viewStudent') |
---|
| 84 | icon = 'actionicon_pdf.png' |
---|
| 85 | text = _('Download Library Id Card') |
---|
| 86 | target = 'lib_idcard.pdf' |
---|
| 87 | |
---|
| 88 | @property |
---|
| 89 | def target_url(self): |
---|
| 90 | if self.context.library: |
---|
| 91 | return self.view.url(self.view.context, self.target) |
---|
| 92 | return |
---|
| 93 | |
---|
[15650] | 94 | # Signature |
---|
| 95 | |
---|
| 96 | class SignatureDisplay(StudentFileDisplay): |
---|
| 97 | """Signature display viewlet. |
---|
| 98 | """ |
---|
| 99 | grok.order(2) |
---|
| 100 | label = _(u'Signature') |
---|
| 101 | title = _(u'Signature Scan') |
---|
| 102 | download_name = u'signature' |
---|
| 103 | |
---|
| 104 | class SignatureSlip(SignatureDisplay): |
---|
| 105 | grok.view(ExportPDFClearanceSlip) |
---|
| 106 | |
---|
| 107 | class SignatureUpload(StudentFileUpload): |
---|
| 108 | """Signature upload viewlet. |
---|
| 109 | """ |
---|
| 110 | grok.order(2) |
---|
| 111 | label = _(u'Signature') |
---|
| 112 | title = _(u'Signature Scan') |
---|
| 113 | download_name = u'signature' |
---|
| 114 | |
---|
| 115 | class SignatureImage(StudentImage): |
---|
[15942] | 116 | """Renders signature scan. |
---|
[15650] | 117 | """ |
---|
| 118 | grok.name('signature') |
---|
| 119 | download_name = u'signature' |
---|
| 120 | |
---|
[15849] | 121 | class SignatureDownloadButton(ManageActionButton): |
---|
| 122 | |
---|
| 123 | grok.order(12) |
---|
| 124 | grok.context(IStudent) |
---|
| 125 | grok.view(StudentBaseDisplayFormPage) |
---|
| 126 | grok.require('waeup.manageStudent') |
---|
| 127 | target = 'signature' |
---|
| 128 | text = _('Signature') |
---|
| 129 | icon = 'actionicon_signature.png' |
---|
| 130 | |
---|
| 131 | @property |
---|
| 132 | def target_url(self): |
---|
| 133 | image = getUtility(IExtFileStore).getFileByContext( |
---|
| 134 | self.context, attr='signature') |
---|
| 135 | if not image: |
---|
| 136 | return '' |
---|
| 137 | return self.view.url(self.view.context, self.target) |
---|
| 138 | |
---|
[15654] | 139 | # JAMB Result |
---|
| 140 | |
---|
| 141 | class JAMBResultDisplay(StudentFileDisplay): |
---|
| 142 | """JAMB Result display viewlet. |
---|
| 143 | """ |
---|
| 144 | grok.order(9) |
---|
| 145 | label = _(u'JAMB Result') |
---|
| 146 | title = _(u'JAMB Result') |
---|
| 147 | download_name = u'jamb' |
---|
| 148 | |
---|
| 149 | class JAMBResultSlip(JAMBResultDisplay): |
---|
| 150 | grok.view(ExportPDFClearanceSlip) |
---|
| 151 | |
---|
| 152 | class JAMBResultUpload(StudentFileUpload): |
---|
| 153 | """JAMB Result upload viewlet. |
---|
| 154 | """ |
---|
| 155 | grok.order(9) |
---|
| 156 | label = _(u'JAMB Result') |
---|
| 157 | title = _(u'JAMB Result Scan') |
---|
| 158 | download_name = u'jamb' |
---|
| 159 | |
---|
| 160 | class JAMBResultImage(StudentImage): |
---|
| 161 | """Renders JAMB Result scan. |
---|
| 162 | """ |
---|
| 163 | grok.name('jamb') |
---|
| 164 | download_name = u'jamb' |
---|
| 165 | |
---|