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

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

Rename stateresult file and adjust to base package.

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