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

Last change on this file since 17389 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
Line 
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
20from zope.component import getUtility
21from waeup.kofa.interfaces import REQUESTED, IExtFileStore
22from waeup.kofa.browser.viewlets import ManageActionButton
23from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
24from kofacustom.iuokada.students.interfaces import (
25    ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent,
26    ICustomStudentStudyCourse)
27from waeup.kofa.students.fileviewlets import (
28    StudentFileDisplay, StudentFileUpload, StudentImage)
29from waeup.kofa.students.browser import (
30    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
31    StudyLevelDisplayFormPage, StudentBaseDisplayFormPage,
32    StudentPersonalEditFormPage)
33from waeup.kofa.students.viewlets import (
34    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
35    StudentPersonalEditActionButton)
36
37from kofacustom.nigeria.interfaces import MessageFactory as _
38
39class StudentPersonalEditActionButton(StudentPersonalEditActionButton):
40    text = _('Edit registration bio data')
41
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
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
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
66class EditBioDataActionButton(ManageActionButton):
67    grok.order(9)
68    grok.context(ICustomStudent)
69    grok.view(StudentBaseDisplayFormPage)
70    grok.require('waeup.handleStudent')
71    text = _('Edit registration bio data now')
72    target = 'edit_personal'
73
74    @property
75    def target_url(self):
76        #if not self.context.is_fresh:
77        #    return ''
78        return self.view.url(self.view.context, self.target)
79
80class PersonalDataSlipActionButton(ManageActionButton):
81    grok.order(10)
82    grok.context(ICustomStudent)
83    grok.view(StudentPersonalEditFormPage)
84    grok.require('waeup.viewStudent')
85    text = _('Download bio data slip')
86    target = 'course_registration_clearance.pdf'
87    icon = 'actionicon_pdf.png'
88
89    @property
90    def target_url(self):
91        if not self.context.minimumStudentPayments():
92            return ''
93        #if not self.context.is_fresh:
94        #    return ''
95        return self.view.url(self.view.context, self.target)
96
97class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
98    grok.require('waeup.payStudent')
99
100    @property
101    def target_url(self):
102        #if self.context.student.depcode == 'BMS':
103        #    return ''
104        return self.view.url(self.view.context, self.target)
105
106class GetMatricNumberActionButton(ManageActionButton):
107    grok.order(10)
108    grok.context(ICustomStudent)
109    grok.view(StudentBaseDisplayFormPage)
110    grok.require('waeup.manageStudent')
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
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
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
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):
173    """Renders signature scan.
174    """
175    grok.name('signature')
176    download_name = u'signature'
177
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
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.