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

Last change on this file since 16137 was 16087, checked in by Henrik Bettermann, 5 years ago

Add base data slip download button.

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