source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/viewlets.py @ 17240

Last change on this file since 17240 was 17136, checked in by Henrik Bettermann, 2 years ago

Re-enable balance payment button.

  • Property svn:keywords set to Id
File size: 6.8 KB
RevLine 
[10765]1## $Id: viewlets.py 17136 2022-10-19 12:49:50Z 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
19import grok
[15802]20from zope.component import getUtility
[15849]21from waeup.kofa.interfaces import REQUESTED, IExtFileStore
[10765]22from waeup.kofa.browser.viewlets import ManageActionButton
[15802]23from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
[15563]24from kofacustom.iuokada.students.interfaces import (
[16087]25    ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent,
26    ICustomStudentStudyCourse)
[12430]27from waeup.kofa.students.fileviewlets import (
[12450]28    StudentFileDisplay, StudentFileUpload, StudentImage)
[10765]29from waeup.kofa.students.browser import (
[13062]30    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
[16410]31    StudyLevelDisplayFormPage, StudentBaseDisplayFormPage,
32    StudentPersonalEditFormPage)
[16015]33from waeup.kofa.students.viewlets import (
[16252]34    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
35    StudentPersonalEditActionButton)
[10765]36
37from kofacustom.nigeria.interfaces import MessageFactory as _
[15650]38
[16252]39class StudentPersonalEditActionButton(StudentPersonalEditActionButton):
[16256]40    text = _('Edit registration bio data')
[16252]41
[16258]42    @property
43    def target_url(self):
44        if not self.context.is_fresh:
45            return ''
46        return self.view.url(self.view.context, self.target)
47
[15859]48class SwitchLibraryAccessActionButton(ManageActionButton):
49    grok.order(7)
50    grok.context(ICustomStudent)
51    grok.view(StudentBaseDisplayFormPage)
52    grok.require('waeup.switchLibraryAccess')
53    text = _('Switch library access')
54    target = 'switch_library_access'
55    icon = 'actionicon_book.png'
56
[16154]57class MakePaymentActionButton(ManageActionButton):
58    grok.order(8)
59    grok.context(ICustomStudent)
60    grok.view(StudentBaseDisplayFormPage)
61    grok.require('waeup.handleStudent')
62    text = _('Make payment now')
63    target = 'payments/addop'
64    icon = 'actionicon_pay.png'
65
[16256]66class EditBioDataActionButton(ManageActionButton):
[16252]67    grok.order(9)
68    grok.context(ICustomStudent)
69    grok.view(StudentBaseDisplayFormPage)
70    grok.require('waeup.handleStudent')
[16256]71    text = _('Edit registration bio data now')
[16252]72    target = 'edit_personal'
73
[16258]74    @property
75    def target_url(self):
[16298]76        #if not self.context.is_fresh:
77        #    return ''
[16258]78        return self.view.url(self.view.context, self.target)
79
[16252]80class PersonalDataSlipActionButton(ManageActionButton):
[16087]81    grok.order(10)
[16252]82    grok.context(ICustomStudent)
[16410]83    grok.view(StudentPersonalEditFormPage)
[16087]84    grok.require('waeup.viewStudent')
[16256]85    text = _('Download bio data slip')
[16295]86    target = 'course_registration_clearance.pdf'
[16087]87    icon = 'actionicon_pdf.png'
88
[16258]89    @property
90    def target_url(self):
[16410]91        if not self.context.minimumStudentPayments():
92            return ''
[16298]93        #if not self.context.is_fresh:
94        #    return ''
[16258]95        return self.view.url(self.view.context, self.target)
96
[16015]97class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
[16031]98    grok.require('waeup.payStudent')
[15859]99
[17126]100    @property
101    def target_url(self):
[17136]102        #if self.context.student.depcode == 'BMS':
103        #    return ''
[17126]104        return self.view.url(self.view.context, self.target)
105
[15802]106class GetMatricNumberActionButton(ManageActionButton):
107    grok.order(10)
[16252]108    grok.context(ICustomStudent)
[15802]109    grok.view(StudentBaseDisplayFormPage)
[15805]110    grok.require('waeup.manageStudent')
[15802]111    icon = 'actionicon_count.png'
112    text = _('Get Matriculation Number')
113
114    @property
115    def target_url(self):
116        students_utils = getUtility(IStudentsUtils)
117        if self.context.matric_number:
118            return ''
119        error, matric_number = students_utils.constructMatricNumber(
120            self.context)
121        if error:
122            return ''
123        return self.view.url(self.view.context, 'get_matric_number')
124
[16252]125class StudyCourseDataSlipActionButton(ManageActionButton):
126    grok.order(10)
127    grok.context(ICustomStudentStudyCourse)
128    grok.view(StudyCourseDisplayFormPage)
129    grok.require('waeup.viewStudent')
130    text = _('Download study course slip')
131    target = 'studycourse_slip.pdf'
132    icon = 'actionicon_pdf.png'
133
[15859]134# Library
135
136class LibraryIdCardActionButton(ManageActionButton):
137    grok.order(10)
138    grok.context(ICustomStudent)
139    grok.view(StudentBaseDisplayFormPage)
140    grok.require('waeup.viewStudent')
141    icon = 'actionicon_pdf.png'
142    text = _('Download Library Id Card')
143    target = 'lib_idcard.pdf'
144
145    @property
146    def target_url(self):
147        if self.context.library:
148            return self.view.url(self.view.context, self.target)
149        return
150
[15650]151# Signature
152
153class SignatureDisplay(StudentFileDisplay):
154    """Signature display viewlet.
155    """
156    grok.order(2)
157    label = _(u'Signature')
158    title = _(u'Signature Scan')
159    download_name = u'signature'
160
161class SignatureSlip(SignatureDisplay):
162    grok.view(ExportPDFClearanceSlip)
163
164class SignatureUpload(StudentFileUpload):
165    """Signature upload viewlet.
166    """
167    grok.order(2)
168    label = _(u'Signature')
169    title = _(u'Signature Scan')
170    download_name = u'signature'
171
172class SignatureImage(StudentImage):
[15942]173    """Renders signature scan.
[15650]174    """
175    grok.name('signature')
176    download_name = u'signature'
177
[15849]178class SignatureDownloadButton(ManageActionButton):
179
180    grok.order(12)
181    grok.context(IStudent)
182    grok.view(StudentBaseDisplayFormPage)
183    grok.require('waeup.manageStudent')
184    target = 'signature'
185    text = _('Signature')
186    icon = 'actionicon_signature.png'
187
188    @property
189    def target_url(self):
190        image = getUtility(IExtFileStore).getFileByContext(
191            self.context, attr='signature')
192        if not image:
193            return ''
194        return self.view.url(self.view.context, self.target)
195
[15654]196# JAMB Result
197
198class JAMBResultDisplay(StudentFileDisplay):
199    """JAMB Result display viewlet.
200    """
201    grok.order(9)
202    label = _(u'JAMB Result')
203    title = _(u'JAMB Result')
204    download_name = u'jamb'
205
206class JAMBResultSlip(JAMBResultDisplay):
207    grok.view(ExportPDFClearanceSlip)
208
209class JAMBResultUpload(StudentFileUpload):
210    """JAMB Result upload viewlet.
211    """
212    grok.order(9)
213    label = _(u'JAMB Result')
214    title = _(u'JAMB Result Scan')
215    download_name = u'jamb'
216
217class JAMBResultImage(StudentImage):
218    """Renders JAMB Result scan.
219    """
220    grok.name('jamb')
221    download_name = u'jamb'
222
Note: See TracBrowser for help on using the repository browser.