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

Last change on this file since 16410 was 16410, checked in by Henrik Bettermann, 4 years ago

minimumStudentPayments does not apply to JUPEB students.

A student who does not meet the requirement should not be able to Download the Bio Data Slip.

  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1## $Id: viewlets.py 16410 2021-03-08 11:44:54Z 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
100class GetMatricNumberActionButton(ManageActionButton):
101    grok.order(10)
102    grok.context(ICustomStudent)
103    grok.view(StudentBaseDisplayFormPage)
104    grok.require('waeup.manageStudent')
105    icon = 'actionicon_count.png'
106    text = _('Get Matriculation Number')
107
108    @property
109    def target_url(self):
110        students_utils = getUtility(IStudentsUtils)
111        if self.context.matric_number:
112            return ''
113        error, matric_number = students_utils.constructMatricNumber(
114            self.context)
115        if error:
116            return ''
117        return self.view.url(self.view.context, 'get_matric_number')
118
119class StudyCourseDataSlipActionButton(ManageActionButton):
120    grok.order(10)
121    grok.context(ICustomStudentStudyCourse)
122    grok.view(StudyCourseDisplayFormPage)
123    grok.require('waeup.viewStudent')
124    text = _('Download study course slip')
125    target = 'studycourse_slip.pdf'
126    icon = 'actionicon_pdf.png'
127
128# Library
129
130class LibraryIdCardActionButton(ManageActionButton):
131    grok.order(10)
132    grok.context(ICustomStudent)
133    grok.view(StudentBaseDisplayFormPage)
134    grok.require('waeup.viewStudent')
135    icon = 'actionicon_pdf.png'
136    text = _('Download Library Id Card')
137    target = 'lib_idcard.pdf'
138
139    @property
140    def target_url(self):
141        if self.context.library:
142            return self.view.url(self.view.context, self.target)
143        return
144
145# Signature
146
147class SignatureDisplay(StudentFileDisplay):
148    """Signature display viewlet.
149    """
150    grok.order(2)
151    label = _(u'Signature')
152    title = _(u'Signature Scan')
153    download_name = u'signature'
154
155class SignatureSlip(SignatureDisplay):
156    grok.view(ExportPDFClearanceSlip)
157
158class SignatureUpload(StudentFileUpload):
159    """Signature upload viewlet.
160    """
161    grok.order(2)
162    label = _(u'Signature')
163    title = _(u'Signature Scan')
164    download_name = u'signature'
165
166class SignatureImage(StudentImage):
167    """Renders signature scan.
168    """
169    grok.name('signature')
170    download_name = u'signature'
171
172class SignatureDownloadButton(ManageActionButton):
173
174    grok.order(12)
175    grok.context(IStudent)
176    grok.view(StudentBaseDisplayFormPage)
177    grok.require('waeup.manageStudent')
178    target = 'signature'
179    text = _('Signature')
180    icon = 'actionicon_signature.png'
181
182    @property
183    def target_url(self):
184        image = getUtility(IExtFileStore).getFileByContext(
185            self.context, attr='signature')
186        if not image:
187            return ''
188        return self.view.url(self.view.context, self.target)
189
190# JAMB Result
191
192class JAMBResultDisplay(StudentFileDisplay):
193    """JAMB Result display viewlet.
194    """
195    grok.order(9)
196    label = _(u'JAMB Result')
197    title = _(u'JAMB Result')
198    download_name = u'jamb'
199
200class JAMBResultSlip(JAMBResultDisplay):
201    grok.view(ExportPDFClearanceSlip)
202
203class JAMBResultUpload(StudentFileUpload):
204    """JAMB Result upload viewlet.
205    """
206    grok.order(9)
207    label = _(u'JAMB Result')
208    title = _(u'JAMB Result Scan')
209    download_name = u'jamb'
210
211class JAMBResultImage(StudentImage):
212    """Renders JAMB Result scan.
213    """
214    grok.name('jamb')
215    download_name = u'jamb'
216
Note: See TracBrowser for help on using the repository browser.