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

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

Add signature download button.

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1## $Id: viewlets.py 15849 2019-11-25 16:06:33Z 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)
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 GetMatricNumberActionButton(ManageActionButton):
35    grok.order(10)
36    grok.context(IStudent)
37    grok.view(StudentBaseDisplayFormPage)
38    grok.require('waeup.manageStudent')
39    icon = 'actionicon_count.png'
40    text = _('Get Matriculation Number')
41
42    @property
43    def target_url(self):
44        students_utils = getUtility(IStudentsUtils)
45        if self.context.matric_number:
46            return ''
47        error, matric_number = students_utils.constructMatricNumber(
48            self.context)
49        if error:
50            return ''
51        return self.view.url(self.view.context, 'get_matric_number')
52
53# Signature
54
55class SignatureDisplay(StudentFileDisplay):
56    """Signature display viewlet.
57    """
58    grok.order(2)
59    label = _(u'Signature')
60    title = _(u'Signature Scan')
61    download_name = u'signature'
62
63class SignatureSlip(SignatureDisplay):
64    grok.view(ExportPDFClearanceSlip)
65
66class SignatureUpload(StudentFileUpload):
67    """Signature upload viewlet.
68    """
69    grok.order(2)
70    label = _(u'Signature')
71    title = _(u'Signature Scan')
72    download_name = u'signature'
73    tab_redirect = '?tab2'
74
75class SignatureImage(StudentImage):
76    """Renders acceptance letter scan.
77    """
78    grok.name('signature')
79    download_name = u'signature'
80
81class SignatureDownloadButton(ManageActionButton):
82
83    grok.order(12)
84    grok.context(IStudent)
85    grok.view(StudentBaseDisplayFormPage)
86    grok.require('waeup.manageStudent')
87    target = 'signature'
88    text = _('Signature')
89    icon = 'actionicon_signature.png'
90
91    @property
92    def target_url(self):
93        image = getUtility(IExtFileStore).getFileByContext(
94            self.context, attr='signature')
95        if not image:
96            return ''
97        return self.view.url(self.view.context, self.target)
98
99# JAMB Result
100
101class JAMBResultDisplay(StudentFileDisplay):
102    """JAMB Result display viewlet.
103    """
104    grok.order(9)
105    label = _(u'JAMB Result')
106    title = _(u'JAMB Result')
107    download_name = u'jamb'
108
109class JAMBResultSlip(JAMBResultDisplay):
110    grok.view(ExportPDFClearanceSlip)
111
112class JAMBResultUpload(StudentFileUpload):
113    """JAMB Result upload viewlet.
114    """
115    grok.order(9)
116    label = _(u'JAMB Result')
117    title = _(u'JAMB Result Scan')
118    download_name = u'jamb'
119
120class JAMBResultImage(StudentImage):
121    """Renders JAMB Result scan.
122    """
123    grok.name('jamb')
124    download_name = u'jamb'
125
Note: See TracBrowser for help on using the repository browser.