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

Last change on this file since 16827 was 16808, checked in by Henrik Bettermann, 3 years ago

Provide button.

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