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