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

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

Add exam schedule examination slip.

Fix test.

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