source: main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py @ 13100

Last change on this file since 13100 was 13063, checked in by Henrik Bettermann, 9 years ago

Rename views.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1## $Id: viewlets.py 13063 2015-06-16 14:10: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 waeup.kofa.interfaces import REQUESTED, REGISTERED
21from waeup.kofa.browser.viewlets import ManageActionButton
22from waeup.uniben.students.interfaces import (
23    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
24    ICustomStudent, )
25from waeup.kofa.students.fileviewlets import (
26    StudentFileDisplay, StudentFileUpload, StudentImage)
27from waeup.kofa.students.browser import (
28    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
29    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage)
30
31from kofacustom.nigeria.interfaces import MessageFactory as _
32
33class StudyCourseEditActionButton(ManageActionButton):
34    grok.order(1)
35    grok.context(ICustomStudentStudyCourse)
36    grok.view(StudyCourseDisplayFormPage)
37    grok.require('waeup.clearStudent')
38    text = _('Edit level')
39    target = 'edit_level'
40
41    @property
42    def target_url(self):
43        if self.context.is_current and self.context.student.state == REQUESTED:
44            return self.view.url(self.view.context, self.target)
45        return False
46
47class CourseRegistrationSlipActionButton(ManageActionButton):
48    grok.order(5)
49    grok.context(ICustomStudentStudyLevel)
50    grok.view(StudyLevelDisplayFormPage)
51    grok.require('waeup.viewStudent')
52    icon = 'actionicon_pdf.png'
53    text = _('Download course registration slip')
54    target = 'course_registration_slip.pdf'
55
56    @property
57    def target_url(self):
58        is_current = self.context.__parent__.is_current
59        if not is_current:
60            return ''
61        if self.context.student.state != REGISTERED \
62            or self.context.student.current_level != self.context.level:
63            return ''
64        return self.view.url(self.view.context, self.target)
65
66class CourseResultSlipActionButton(ManageActionButton):
67    grok.order(6)
68    grok.context(ICustomStudentStudyLevel)
69    grok.view(StudyLevelDisplayFormPage)
70    grok.require('waeup.viewStudent')
71    icon = 'actionicon_pdf.png'
72    text = _('Download course result slip')
73    target = 'course_result_slip.pdf'
74
75    @property
76    def target_url(self):
77        return self.view.url(self.view.context, self.target)
78
79
80class ClearanceInvitationSlipActionButton(ManageActionButton):
81    grok.order(5)
82    grok.context(ICustomStudent)
83    grok.view(StudentClearanceDisplayFormPage)
84    grok.require('waeup.viewStudent')
85    icon = 'actionicon_pdf.png'
86    text = _('Download clearance invitation slip')
87    target = 'clearance_invitation_slip.pdf'
88
89    @property
90    def target_url(self):
91        if self.context.student.state == REQUESTED \
92            and self.context.student.physical_clearance_date:
93            return self.view.url(self.view.context, self.target)
94        return False
95
96
97# JAMB Letter
98
99class JAMBLetterDisplay(StudentFileDisplay):
100    """JAMB Letter display viewlet.
101    """
102    grok.order(19)
103    label = _(u'JAMB Letter')
104    title = _(u'JAMB Letter')
105    download_name = u'jamb_letter'
106
107class JAMBLetterSlip(JAMBLetterDisplay):
108    grok.view(ExportPDFClearanceSlip)
109
110class JAMBLetterUpload(StudentFileUpload):
111    """JAMB Letter upload viewlet.
112    """
113    grok.order(19)
114    label = _(u'JAMB Letter')
115    title = _(u'JAMB Letter Scan')
116    mus = 1024 * 150
117    download_name = u'jamb_letter'
118
119class JAMBLetterImage(StudentImage):
120    """Renders JAMB Letter scan.
121    """
122    grok.name('jamb_letter')
123    download_name = u'jamb_letter'
124
125# Affidavit of Non-Membership of Secret Cults
126
127class SecrCultsStatementDisplay(StudentFileDisplay):
128    """Affidavit of Non-Membership of Secret Cults display viewlet.
129    """
130    grok.order(20)
131    label = _(u'Affidavit of Non-Membership of Secret Cults')
132    title = _(u'Affidavit of Non-Membership of Secret Cults')
133    download_name = u'secr_cults'
134
135class SecrCultsStatementSlip(SecrCultsStatementDisplay):
136    grok.view(ExportPDFClearanceSlip)
137
138class SecrCultsStatementUpload(StudentFileUpload):
139    """Affidavit of Non-Membership of Secret Cults upload viewlet.
140    """
141    grok.order(20)
142    label = _(u'Affidavit of Non-Membership of Secret Cults')
143    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
144    mus = 1024 * 150
145    download_name = u'secr_cults'
146
147class SecrCultsStatementImage(StudentImage):
148    """Renders Affidavit of Non-Membership of Secret Cults scan.
149    """
150    grok.name('secr_cults')
151    download_name = u'secr_cults'
152
153# Fingerprints
154
155class LeftThumbPrintDisplay(StudentFileDisplay):
156    """Left thumb fingerprint display viewlet.
157    """
158    grok.order(21)
159    label = _(u'Left Thumb Fingerprint')
160    title = _(u'Left Thumb Fingerprint Minutiae')
161    download_name = u'finger1.fpm'
162
163class LeftThumbPrintSlip(LeftThumbPrintDisplay):
164    """Mentions scanned fingerprint on slip.
165
166    Fingerprint minutiae is not printet.
167    """
168    grok.view(ExportPDFClearanceSlip)
169
170class LeftThumbPrintUpload(StudentFileUpload):
171    """Left thumb fingerprint upload viewlet.
172    """
173    grok.order(21)
174    grok.require('waeup.manageStudent')
175    label = _(u'Left Thumb Fingerprint')
176    title = _(u'Left Thumb Fingerprint Minutiae')
177    mus = 1024 * 5
178    download_name = u'finger1.fpm'
179
180class LeftThumbPrintImage(StudentImage):
181    """Renders left thumb fingerprint minutiae for download.
182    """
183    grok.name('finger1.fpm')
184    download_name = u'finger1.fpm'
Note: See TracBrowser for help on using the repository browser.