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

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

Rename file.

Customize texts.

  • Property svn:keywords set to Id
File size: 11.0 KB
Line 
1## $Id: viewlets.py 16443 2021-04-01 20:01:29Z 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, REGISTERED, IExtFileStore
22from waeup.kofa.browser.viewlets import ManageActionButton
23from waeup.kofa.students.interfaces import IStudentsUtils
24from waeup.kofa.students.fileviewlets import (
25    StudentFileDisplay, StudentFileUpload, StudentImage, PassportDisplay)
26from waeup.kofa.students.browser import (
27    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
28    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
29    StudentBaseDisplayFormPage)
30from waeup.kofa.students.viewlets import (
31    RequestTranscriptActionButton, StudentPassportActionButton)
32
33from waeup.uniben.students.interfaces import (
34    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
35    ICustomStudent,)
36
37from waeup.uniben.students.browser import StudentMedicalHistoryEditFormPage
38
39from kofacustom.nigeria.interfaces import MessageFactory as _
40
41class CustomRequestTranscriptActionButton(RequestTranscriptActionButton):
42
43    @property
44    def target_url(self):
45        return ''
46
47class CustomStudentPassportActionButton(StudentPassportActionButton):
48
49    @property
50    def target_url(self):
51        # Uniben: Only 2020 session students are allowed to edit the picture.
52        if self.context.entry_session != 2020:
53            return ''
54        # Passport pictures must not be editable if application slip
55        # exists.
56        slip = getUtility(IExtFileStore).getFileByContext(
57            self.context, 'application_slip')
58        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
59        if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None:
60            return ''
61        return self.view.url(self.view.context, self.target)
62
63class SwitchLibraryAccessActionButton(ManageActionButton):
64    grok.order(7)
65    grok.context(ICustomStudent)
66    grok.view(StudentBaseDisplayFormPage)
67    grok.require('waeup.switchLibraryAccess')
68    text = _('Switch library access')
69    target = 'switch_library_access'
70    icon = 'actionicon_book.png'
71
72class StudyCourseEditActionButton(ManageActionButton):
73    grok.order(1)
74    grok.context(ICustomStudentStudyCourse)
75    grok.view(StudyCourseDisplayFormPage)
76    grok.require('waeup.clearStudent')
77    text = _('Edit level')
78    target = 'edit_level'
79
80    @property
81    def target_url(self):
82        if self.context.is_current and self.context.student.state == REQUESTED:
83            return self.view.url(self.view.context, self.target)
84        return False
85
86class CourseRegistrationSlipActionButton(ManageActionButton):
87    grok.order(5)
88    grok.context(ICustomStudentStudyLevel)
89    grok.view(StudyLevelDisplayFormPage)
90    grok.require('waeup.viewStudent')
91    icon = 'actionicon_pdf.png'
92    text = _('Download course registration slip')
93    target = 'course_registration_slip.pdf'
94
95    @property
96    def target_url(self):
97        is_current = self.context.__parent__.is_current
98        if not is_current:
99            return ''
100        if self.context.student.state != REGISTERED \
101            or self.context.student.current_level != self.context.level:
102            return ''
103        return self.view.url(self.view.context, self.target)
104
105class CourseResultSlipActionButton(ManageActionButton):
106    grok.order(6)
107    grok.context(ICustomStudentStudyLevel)
108    grok.view(StudyLevelDisplayFormPage)
109    grok.require('waeup.viewStudent')
110    icon = 'actionicon_pdf.png'
111    text = _('Download course result slip')
112    target = 'course_result_slip.pdf'
113
114    @property
115    def target_url(self):
116        return self.view.url(self.view.context, self.target)
117
118
119class ClearanceInvitationSlipActionButton(ManageActionButton):
120    grok.order(5)
121    grok.context(ICustomStudent)
122    grok.view(StudentClearanceDisplayFormPage)
123    grok.require('waeup.viewStudent')
124    icon = 'actionicon_pdf.png'
125    text = _('Download clearance invitation slip')
126    target = 'clearance_invitation_slip.pdf'
127
128    @property
129    def target_url(self):
130        if self.context.student.state == REQUESTED \
131            and self.context.student.physical_clearance_date:
132            return self.view.url(self.view.context, self.target)
133        return False
134
135class ExaminationScheduleSlipActionButton(ManageActionButton):
136    grok.order(10)
137    grok.context(ICustomStudent)
138    grok.view(StudentBaseDisplayFormPage)
139    grok.require('waeup.viewStudent')
140    icon = 'actionicon_pdf.png'
141    text = _('Download examination schedule slip')
142    target = 'examination_schedule_slip.pdf'
143
144    @property
145    def target_url(self):
146        if self.context.flash_notice \
147            and 'exam' in self.context.flash_notice.lower():
148            return self.view.url(self.view.context, self.target)
149        return False
150
151class JHLIdCardActionButton(ManageActionButton):
152    grok.order(10)
153    grok.context(ICustomStudent)
154    grok.view(StudentBaseDisplayFormPage)
155    grok.require('waeup.viewStudent')
156    icon = 'actionicon_pdf.png'
157    text = _('Download JHL Id Card')
158    target = 'jhl_idcard.pdf'
159
160    @property
161    def target_url(self):
162        if self.context.library:
163            return self.view.url(self.view.context, self.target)
164        return
165
166class JUPEBResultSlipActionButton(ManageActionButton):
167    grok.order(11)
168    grok.context(ICustomStudent)
169    grok.view(StudentBaseDisplayFormPage)
170    grok.require('waeup.viewStudent')
171    icon = 'actionicon_pdf.png'
172    text = _('Download JUPEB result slip')
173    target = 'jupeb_result_slip.pdf'
174
175    @property
176    def target_url(self):
177        if self.context.flash_notice and self.context.is_jupeb \
178            and 'results' in self.context.flash_notice.lower():
179            return self.view.url(self.view.context, self.target)
180        return False
181
182class MedicalHistoryEditActionButton(ManageActionButton):
183    grok.order(12)
184    grok.context(ICustomStudent)
185    grok.view(StudentBaseDisplayFormPage)
186    grok.require('waeup.handleStudent')
187    text = _('Medical Questionnaire')
188    target = 'edit_medical'
189    icon = 'actionicon_medical.png'
190
191class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
192    grok.require('waeup.manageStudent')
193    text = _('Manage medical history')
194    target = 'manage_medical'
195
196class MedicalHistorySlipActionButton(ManageActionButton):
197    grok.order(1)
198    grok.context(ICustomStudent)
199    grok.view(StudentMedicalHistoryEditFormPage)
200    grok.require('waeup.viewStudent')
201    icon = 'actionicon_pdf.png'
202    text = _('Download medical questionnaire slip')
203    target = 'medical_questionnaire_slip.pdf'
204
205# JAMB Letter
206
207class JAMBLetterDisplay(StudentFileDisplay):
208    """JAMB Letter display viewlet.
209    """
210    grok.order(19)
211    label = _(u'JAMB Letter')
212    title = _(u'JAMB Letter')
213    download_name = u'jamb_letter'
214
215class JAMBLetterSlip(JAMBLetterDisplay):
216    grok.view(ExportPDFClearanceSlip)
217
218class JAMBLetterUpload(StudentFileUpload):
219    """JAMB Letter upload viewlet.
220    """
221    grok.order(19)
222    label = _(u'JAMB Letter')
223    title = _(u'JAMB Letter Scan')
224    mus = 1024 * 150
225    download_name = u'jamb_letter'
226
227class JAMBLetterImage(StudentImage):
228    """Renders JAMB Letter scan.
229    """
230    grok.name('jamb_letter')
231    download_name = u'jamb_letter'
232
233# Affidavit of Non-Membership of Secret Cults
234
235class SecrCultsStatementDisplay(StudentFileDisplay):
236    """Affidavit of Non-Membership of Secret Cults display viewlet.
237    """
238    grok.order(20)
239    label = _(u'Affidavit of Non-Membership of Secret Cults')
240    title = _(u'Affidavit of Non-Membership of Secret Cults')
241    download_name = u'secr_cults'
242
243class SecrCultsStatementSlip(SecrCultsStatementDisplay):
244    grok.view(ExportPDFClearanceSlip)
245
246class SecrCultsStatementUpload(StudentFileUpload):
247    """Affidavit of Non-Membership of Secret Cults upload viewlet.
248    """
249    grok.order(20)
250    label = _(u'Affidavit of Non-Membership of Secret Cults')
251    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
252    mus = 1024 * 150
253    download_name = u'secr_cults'
254
255class SecrCultsStatementImage(StudentImage):
256    """Renders Affidavit of Non-Membership of Secret Cults scan.
257    """
258    grok.name('secr_cults')
259    download_name = u'secr_cults'
260
261# O Level Results Scratch Card
262
263class OLevelResultsScratchCardDisplay(StudentFileDisplay):
264    """O'Level Results Scratch Card display viewlet.
265    """
266    grok.order(20)
267    label = _(u'O Level Results Scratch Card')
268    title = _(u'O Level Results Scratch Card')
269    download_name = u'olevel_sc'
270
271class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
272    grok.view(ExportPDFClearanceSlip)
273
274class OLevelResultsScratchCardUpload(StudentFileUpload):
275    """O Level Results Scratch Card upload viewlet.
276    """
277    grok.order(20)
278    label = _(u'O Level Results Scratch Card')
279    title = _(u'O Level Results Scratch Card Scan')
280    mus = 1024 * 150
281    download_name = u'olevel_sc'
282
283class OLevelResultsScratchCardImage(StudentImage):
284    """Renders O Level Results Scratch Card scan.
285    """
286    grok.name('olevel_sc')
287    download_name = u'olevel_sc'
288
289# Fingerprints
290
291class LeftThumbPrintDisplay(StudentFileDisplay):
292    """Left thumb fingerprint display viewlet.
293    """
294    grok.order(21)
295    label = _(u'Left Thumb Fingerprint')
296    title = _(u'Left Thumb Fingerprint Minutiae')
297    download_name = u'finger1.fpm'
298
299class LeftThumbPrintSlip(LeftThumbPrintDisplay):
300    """Mentions scanned fingerprint on slip.
301    Fingerprint minutiae is not printed.
302    """
303    grok.view(ExportPDFClearanceSlip)
304
305class LeftThumbPrintUpload(StudentFileUpload):
306    """Left thumb fingerprint upload viewlet.
307    """
308    grok.order(21)
309    grok.require('waeup.manageStudent')
310    label = _(u'Left Thumb Fingerprint')
311    title = _(u'Left Thumb Fingerprint Minutiae')
312    mus = 1024 * 150
313    download_name = u'finger1.fpm'
314
315class LeftThumbPrintImage(StudentImage):
316    """Renders left thumb fingerprint minutiae for download.
317    """
318    grok.name('finger1.fpm')
319    download_name = u'finger1.fpm'
320
321# O Original JAMB picture (view only))
322
323class JAMBPictureDisplay(PassportDisplay):
324    """Original JAMB picture display viewlet.
325    """
326    grok.order(20)
327    label = _(u'Original JAMB Picture')
328    title = _(u'Original JAMB Picture')
329    download_name = u'passport2'
330
331class JAMBPictureSlip(JAMBPictureDisplay):
332    grok.view(ExportPDFClearanceSlip)
333
334class JAMBPictureImage(StudentImage):
335    """Renders Original JAMB picture.
336    """
337    grok.name('passport2')
338    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.