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

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

Change permissions.

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