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

Last change on this file since 16281 was 16130, checked in by Henrik Bettermann, 4 years ago

Disable CustomRequestTranscriptActionButton?.

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