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

Last change on this file since 17945 was 17661, checked in by Henrik Bettermann, 10 months ago

Further customizations for the CDL portal.

  • Property svn:keywords set to Id
File size: 7.7 KB
Line 
1## $Id: viewlets.py 17661 2024-01-08 17:02:40Z 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, AdmissionSlipActionButton)
36
37from kofacustom.nigeria.interfaces import MessageFactory as _
38
39class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
40
41    @property
42    def target(self):
43        if grok.getSite().__name__ == 'iuokada-cdl':
44            return
45        return 'addpp'
46
47class StudentPersonalEditActionButton(StudentPersonalEditActionButton):
48    text = _('Edit registration bio data')
49
50    @property
51    def target_url(self):
52        if not self.context.is_fresh:
53            return ''
54        return self.view.url(self.view.context, self.target)
55
56class SwitchLibraryAccessActionButton(ManageActionButton):
57    grok.order(7)
58    grok.context(ICustomStudent)
59    grok.view(StudentBaseDisplayFormPage)
60    grok.require('waeup.switchLibraryAccess')
61    text = _('Switch library access')
62    target = 'switch_library_access'
63    icon = 'actionicon_book.png'
64
65class MakePaymentActionButton(ManageActionButton):
66    grok.order(8)
67    grok.context(ICustomStudent)
68    grok.view(StudentBaseDisplayFormPage)
69    grok.require('waeup.handleStudent')
70    text = _('Make payment now')
71    target = 'payments'
72    icon = 'actionicon_pay.png'
73
74class EditBioDataActionButton(ManageActionButton):
75    grok.order(9)
76    grok.context(ICustomStudent)
77    grok.view(StudentBaseDisplayFormPage)
78    grok.require('waeup.handleStudent')
79    text = _('Edit registration bio data now')
80    target = 'edit_personal'
81
82    @property
83    def target_url(self):
84        #if not self.context.is_fresh:
85        #    return ''
86        return self.view.url(self.view.context, self.target)
87
88class PersonalDataSlipActionButton(ManageActionButton):
89    grok.order(10)
90    grok.context(ICustomStudent)
91    grok.view(StudentPersonalEditFormPage)
92    grok.require('waeup.viewStudent')
93    text = _('Download bio data slip')
94    target = 'course_registration_clearance.pdf'
95    icon = 'actionicon_pdf.png'
96
97    @property
98    def target_url(self):
99        if not self.context.minimumStudentPayments():
100            return ''
101        #if not self.context.is_fresh:
102        #    return ''
103        return self.view.url(self.view.context, self.target)
104
105class AdmissionSlipActionButton(AdmissionSlipActionButton):
106
107    @property
108    def target_url(self):
109        if not self.context.is_fresh:
110            return ''
111        return self.view.url(self.view.context, self.target)
112
113class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
114    grok.require('waeup.payStudent')
115
116    @property
117    def target_url(self):
118        #if self.context.student.depcode == 'BMS':
119        #    return ''
120        if grok.getSite().__name__ == 'iuokada-cdl':
121            return
122        return self.view.url(self.view.context, self.target)
123
124class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
125
126    @property
127    def target_url(self):
128        if grok.getSite().__name__ == 'iuokada-cdl':
129            return
130        student = self.view.context.student
131        if student.before_payment or not self.target:
132            return ''
133        return self.view.url(self.view.context, self.target)
134
135class GetMatricNumberActionButton(ManageActionButton):
136    grok.order(10)
137    grok.context(ICustomStudent)
138    grok.view(StudentBaseDisplayFormPage)
139    grok.require('waeup.manageStudent')
140    icon = 'actionicon_count.png'
141    text = _('Get Matriculation Number')
142
143    @property
144    def target_url(self):
145        students_utils = getUtility(IStudentsUtils)
146        if self.context.matric_number:
147            return ''
148        error, matric_number = students_utils.constructMatricNumber(
149            self.context)
150        if error:
151            return ''
152        return self.view.url(self.view.context, 'get_matric_number')
153
154class StudyCourseDataSlipActionButton(ManageActionButton):
155    grok.order(10)
156    grok.context(ICustomStudentStudyCourse)
157    grok.view(StudyCourseDisplayFormPage)
158    grok.require('waeup.viewStudent')
159    text = _('Download study course slip')
160    target = 'studycourse_slip.pdf'
161    icon = 'actionicon_pdf.png'
162
163# Library
164
165class LibraryIdCardActionButton(ManageActionButton):
166    grok.order(10)
167    grok.context(ICustomStudent)
168    grok.view(StudentBaseDisplayFormPage)
169    grok.require('waeup.viewStudent')
170    icon = 'actionicon_pdf.png'
171    text = _('Download Library Id Card')
172    target = 'lib_idcard.pdf'
173
174    @property
175    def target_url(self):
176        if self.context.library:
177            return self.view.url(self.view.context, self.target)
178        return
179
180# Signature
181
182class SignatureDisplay(StudentFileDisplay):
183    """Signature display viewlet.
184    """
185    grok.order(2)
186    label = _(u'Signature')
187    title = _(u'Signature Scan')
188    download_name = u'signature'
189
190class SignatureSlip(SignatureDisplay):
191    grok.view(ExportPDFClearanceSlip)
192
193class SignatureUpload(StudentFileUpload):
194    """Signature upload viewlet.
195    """
196    grok.order(2)
197    label = _(u'Signature')
198    title = _(u'Signature Scan')
199    download_name = u'signature'
200
201class SignatureImage(StudentImage):
202    """Renders signature scan.
203    """
204    grok.name('signature')
205    download_name = u'signature'
206
207class SignatureDownloadButton(ManageActionButton):
208
209    grok.order(12)
210    grok.context(IStudent)
211    grok.view(StudentBaseDisplayFormPage)
212    grok.require('waeup.manageStudent')
213    target = 'signature'
214    text = _('Signature')
215    icon = 'actionicon_signature.png'
216
217    @property
218    def target_url(self):
219        image = getUtility(IExtFileStore).getFileByContext(
220            self.context, attr='signature')
221        if not image:
222            return ''
223        return self.view.url(self.view.context, self.target)
224
225# JAMB Result
226
227class JAMBResultDisplay(StudentFileDisplay):
228    """JAMB Result display viewlet.
229    """
230    grok.order(9)
231    label = _(u'JAMB Result')
232    title = _(u'JAMB Result')
233    download_name = u'jamb'
234
235class JAMBResultSlip(JAMBResultDisplay):
236    grok.view(ExportPDFClearanceSlip)
237
238class JAMBResultUpload(StudentFileUpload):
239    """JAMB Result upload viewlet.
240    """
241    grok.order(9)
242    label = _(u'JAMB Result')
243    title = _(u'JAMB Result Scan')
244    download_name = u'jamb'
245
246class JAMBResultImage(StudentImage):
247    """Renders JAMB Result scan.
248    """
249    grok.name('jamb')
250    download_name = u'jamb'
251
Note: See TracBrowser for help on using the repository browser.