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

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

Further customizations for the CDL portal.

  • Property svn:keywords set to Id
File size: 7.7 KB
RevLine 
[10765]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
[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
[17661]39class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
40
41    @property
42    def target(self):
43        if grok.getSite().__name__ == 'iuokada-cdl':
44            return
45        return 'addpp'
46
[16252]47class StudentPersonalEditActionButton(StudentPersonalEditActionButton):
[16256]48    text = _('Edit registration bio data')
[16252]49
[16258]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
[15859]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
[16154]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')
[17573]71    target = 'payments'
[16154]72    icon = 'actionicon_pay.png'
73
[16256]74class EditBioDataActionButton(ManageActionButton):
[16252]75    grok.order(9)
76    grok.context(ICustomStudent)
77    grok.view(StudentBaseDisplayFormPage)
78    grok.require('waeup.handleStudent')
[16256]79    text = _('Edit registration bio data now')
[16252]80    target = 'edit_personal'
81
[16258]82    @property
83    def target_url(self):
[16298]84        #if not self.context.is_fresh:
85        #    return ''
[16258]86        return self.view.url(self.view.context, self.target)
87
[16252]88class PersonalDataSlipActionButton(ManageActionButton):
[16087]89    grok.order(10)
[16252]90    grok.context(ICustomStudent)
[16410]91    grok.view(StudentPersonalEditFormPage)
[16087]92    grok.require('waeup.viewStudent')
[16256]93    text = _('Download bio data slip')
[16295]94    target = 'course_registration_clearance.pdf'
[16087]95    icon = 'actionicon_pdf.png'
96
[16258]97    @property
98    def target_url(self):
[16410]99        if not self.context.minimumStudentPayments():
100            return ''
[16298]101        #if not self.context.is_fresh:
102        #    return ''
[16258]103        return self.view.url(self.view.context, self.target)
104
[17404]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
[16015]113class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
[16031]114    grok.require('waeup.payStudent')
[15859]115
[17126]116    @property
117    def target_url(self):
[17136]118        #if self.context.student.depcode == 'BMS':
119        #    return ''
[17661]120        if grok.getSite().__name__ == 'iuokada-cdl':
121            return
[17126]122        return self.view.url(self.view.context, self.target)
123
[17661]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
[15802]135class GetMatricNumberActionButton(ManageActionButton):
136    grok.order(10)
[16252]137    grok.context(ICustomStudent)
[15802]138    grok.view(StudentBaseDisplayFormPage)
[15805]139    grok.require('waeup.manageStudent')
[15802]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
[16252]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
[15859]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
[15650]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):
[15942]202    """Renders signature scan.
[15650]203    """
204    grok.name('signature')
205    download_name = u'signature'
206
[15849]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
[15654]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.