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

Last change on this file since 16100 was 15371, checked in by Henrik Bettermann, 6 years ago

Implement a library access switch.

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