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

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

Implement automatic matric number assignment.

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1## $Id: viewlets.py 15802 2019-11-12 22:16:57Z 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
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.viewStudent')
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
81# JAMB Result
82
83class JAMBResultDisplay(StudentFileDisplay):
84    """JAMB Result display viewlet.
85    """
86    grok.order(9)
87    label = _(u'JAMB Result')
88    title = _(u'JAMB Result')
89    download_name = u'jamb'
90
91class JAMBResultSlip(JAMBResultDisplay):
92    grok.view(ExportPDFClearanceSlip)
93
94class JAMBResultUpload(StudentFileUpload):
95    """JAMB Result upload viewlet.
96    """
97    grok.order(9)
98    label = _(u'JAMB Result')
99    title = _(u'JAMB Result Scan')
100    download_name = u'jamb'
101
102class JAMBResultImage(StudentImage):
103    """Renders JAMB Result scan.
104    """
105    grok.name('jamb')
106    download_name = u'jamb'
107
Note: See TracBrowser for help on using the repository browser.