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

Last change on this file since 17421 was 17404, checked in by Henrik Bettermann, 19 months ago

New dates.

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