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

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

Change link.

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