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

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

New dates.

  • Property svn:keywords set to Id
File size: 7.0 KB
RevLine 
[10765]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
[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,
[17404]35    StudentPersonalEditActionButton, AdmissionSlipActionButton)
[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
[17404]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
[16015]105class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
[16031]106    grok.require('waeup.payStudent')
[15859]107
[17126]108    @property
109    def target_url(self):
[17136]110        #if self.context.student.depcode == 'BMS':
111        #    return ''
[17126]112        return self.view.url(self.view.context, self.target)
113
[15802]114class GetMatricNumberActionButton(ManageActionButton):
115    grok.order(10)
[16252]116    grok.context(ICustomStudent)
[15802]117    grok.view(StudentBaseDisplayFormPage)
[15805]118    grok.require('waeup.manageStudent')
[15802]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
[16252]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
[15859]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
[15650]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):
[15942]181    """Renders signature scan.
[15650]182    """
183    grok.name('signature')
184    download_name = u'signature'
185
[15849]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
[15654]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.