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

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

Add 'Make payment now' button.

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