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

Last change on this file since 17881 was 17881, checked in by Henrik Bettermann, 3 months ago

Fix class name.

  • Property svn:keywords set to Id
File size: 14.4 KB
Line 
1## $Id: viewlets.py 17881 2024-08-10 21:23:27Z 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, CLEARED, 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, StudentBaseManageFormPage,
30    OnlinePaymentDisplayFormPage)
31from waeup.kofa.students.viewlets import (
32    RequestTranscriptActionButton,
33    TranscriptSlipActionButton,
34    StudyCourseTranscriptActionButton)
35
36from waeup.uniben.students.interfaces import (
37    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
38    ICustomStudent, ICustomStudentOnlinePayment)
39
40from waeup.uniben.students.browser import (
41    StudentMedicalHistoryEditFormPage, StudentAffidavitUploadPage)
42
43from kofacustom.nigeria.interfaces import MessageFactory as _
44
45class RequestTranscriptActionButton(RequestTranscriptActionButton):
46
47    @property
48    def target_url(self):
49        return ''
50
51class TranscriptSlipActionButton(TranscriptSlipActionButton):
52    grok.require('waeup.viewStudent')
53
54class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
55    grok.require('waeup.viewStudent')
56
57
58class SwitchLibraryAccessActionButton(ManageActionButton):
59    grok.order(7)
60    grok.context(ICustomStudent)
61    grok.view(StudentBaseDisplayFormPage)
62    grok.require('waeup.switchLibraryAccess')
63    text = _('Switch library access')
64    target = 'switch_library_access'
65    icon = 'actionicon_book.png'
66
67class StudyCourseEditActionButton(ManageActionButton):
68    grok.order(1)
69    grok.context(ICustomStudentStudyCourse)
70    grok.view(StudyCourseDisplayFormPage)
71    grok.require('waeup.clearStudent')
72    text = _('Edit level')
73    target = 'edit_level'
74
75    @property
76    def target_url(self):
77        if self.context.is_current and self.context.student.state == REQUESTED:
78            return self.view.url(self.view.context, self.target)
79        return False
80
81class CourseRegistrationSlipActionButton(ManageActionButton):
82    grok.order(5)
83    grok.context(ICustomStudentStudyLevel)
84    grok.view(StudyLevelDisplayFormPage)
85    grok.require('waeup.viewStudent')
86    icon = 'actionicon_pdf.png'
87    text = _('Download course registration slip')
88    target = 'course_registration_slip.pdf'
89
90    @property
91    def target_url(self):
92        is_current = self.context.__parent__.is_current
93        if not is_current:
94            return ''
95        if self.context.student.state != REGISTERED \
96            or self.context.student.current_level != self.context.level:
97            return ''
98        return self.view.url(self.view.context, self.target)
99
100class CourseResultSlipActionButton(ManageActionButton):
101    grok.order(6)
102    grok.context(ICustomStudentStudyLevel)
103    grok.view(StudyLevelDisplayFormPage)
104    grok.require('waeup.viewStudent')
105    icon = 'actionicon_pdf.png'
106    text = _('Download course result slip')
107    target = 'course_result_slip.pdf'
108
109    @property
110    def target_url(self):
111        return self.view.url(self.view.context, self.target)
112
113
114class ClearanceInvitationSlipActionButton(ManageActionButton):
115    grok.order(5)
116    grok.context(ICustomStudent)
117    grok.view(StudentClearanceDisplayFormPage)
118    grok.require('waeup.viewStudent')
119    icon = 'actionicon_pdf.png'
120    text = _('Download clearance invitation slip')
121    target = 'clearance_invitation_slip.pdf'
122
123    @property
124    def target_url(self):
125        if self.context.student.state == REQUESTED \
126            and self.context.student.physical_clearance_date:
127            return self.view.url(self.view.context, self.target)
128        return False
129
130class MadicalExaminationSlipActionButton(ManageActionButton):
131    grok.order(6)
132    grok.context(ICustomStudent)
133    grok.view(StudentClearanceDisplayFormPage)
134    grok.require('waeup.viewStudent')
135    icon = 'actionicon_pdf.png'
136    text = _('Download medical examination slip')
137    target = 'medical_examination_slip.pdf'
138
139    @property
140    def target_url(self):
141        if self.context.student.state == CLEARED \
142            and self.context.student.physical_clearance_date:
143            return self.view.url(self.view.context, self.target)
144        return False
145
146class ExaminationScheduleSlipActionButton(ManageActionButton):
147    grok.order(10)
148    grok.context(ICustomStudent)
149    grok.view(StudentBaseDisplayFormPage)
150    grok.require('waeup.viewStudent')
151    icon = 'actionicon_pdf.png'
152    text = _('Download examination schedule slip')
153    target = 'examination_schedule_slip.pdf'
154
155    @property
156    def target_url(self):
157        if self.context.flash_notice \
158            and 'exam' in self.context.flash_notice.lower():
159            return self.view.url(self.view.context, self.target)
160        return False
161
162class JHLIdCardActionButton(ManageActionButton):
163    grok.order(10)
164    grok.context(ICustomStudent)
165    grok.view(StudentBaseDisplayFormPage)
166    grok.require('waeup.viewStudent')
167    icon = 'actionicon_pdf.png'
168    text = _('Download JHL Id Card')
169    target = 'jhl_idcard.pdf'
170
171    @property
172    def target_url(self):
173        if self.context.library:
174            return self.view.url(self.view.context, self.target)
175        return
176
177class JUPEBResultSlipActionButton(ManageActionButton):
178    grok.order(11)
179    grok.context(ICustomStudent)
180    grok.view(StudentBaseDisplayFormPage)
181    grok.require('waeup.viewStudent')
182    icon = 'actionicon_pdf.png'
183    text = _('Download JUPEB result slip')
184    target = 'jupeb_result_slip.pdf'
185
186    @property
187    def target_url(self):
188        if self.context.flash_notice and self.context.is_jupeb \
189            and 'results' in self.context.flash_notice.lower():
190            return self.view.url(self.view.context, self.target)
191        return False
192
193class MedicalHistoryEditActionButton(ManageActionButton):
194    grok.order(12)
195    grok.context(ICustomStudent)
196    grok.view(StudentBaseDisplayFormPage)
197    grok.require('waeup.handleStudent')
198    text = _('Medical Questionnaire')
199    target = 'edit_medical'
200    icon = 'actionicon_medical.png'
201
202class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
203    grok.require('waeup.manageStudent')
204    text = _('Manage medical history')
205    target = 'manage_medical'
206
207class MedicalHistorySlipActionButton(ManageActionButton):
208    grok.order(1)
209    grok.context(ICustomStudent)
210    grok.view(StudentMedicalHistoryEditFormPage)
211    grok.require('waeup.viewStudent')
212    icon = 'actionicon_pdf.png'
213    text = _('Download medical questionnaire slip')
214    target = 'medical_questionnaire_slip.pdf'
215
216class TishipSlipActionButton(ManageActionButton):
217    grok.order(2)
218    grok.context(ICustomStudent)
219    grok.view(StudentBaseDisplayFormPage)
220    grok.require('waeup.viewStudent')
221    icon = 'actionicon_pdf.png'
222    text = _('Download TISHIP registration slip')
223    target = 'tiship_slip.pdf'
224
225class PlagTestLinkActionButton(ManageActionButton):
226    grok.order(10) 
227    grok.context(ICustomStudentOnlinePayment)
228    grok.view(OnlinePaymentDisplayFormPage)
229    grok.require('waeup.viewStudent')
230    icon = 'actionicon_up.png'
231    text = _('Upload project/thesis file')
232    target = 'plagtestinfo'
233
234    @property
235    def target_url(self):
236        if self.context.p_state != 'paid' \
237            or self.context.p_category != 'plag_test':
238            return ''
239        return self.view.url(self.view.context, self.target)
240
241class NYSCEditActionButton(ManageActionButton):
242    grok.order(13)
243    grok.context(ICustomStudent)
244    grok.view(StudentBaseDisplayFormPage)
245    grok.require('waeup.handleStudent')
246    text = _('NYSC Request')
247    target = 'edit_nysc'
248    icon = 'actionicon_nigeria.png'
249
250    @property
251    def target_url(self):
252        if not self.context.eligible_for_nysc:
253            return ''
254        return self.view.url(self.view.context, self.target)
255
256class NYSCManageActionButton(ManageActionButton):
257    grok.require('waeup.manageStudent')
258    text = _('Manage NYSC request data')
259    target = 'manage_nysc'
260    grok.order(13)
261    grok.context(ICustomStudent)
262    grok.view(StudentBaseDisplayFormPage)
263    icon = 'actionicon_nigeria.png'
264
265# Affidavit of Good Behavior
266
267class StudentAffidavitUploadActionButton(ManageActionButton):
268    grok.order(14)
269    grok.context(ICustomStudent)
270    grok.view(StudentBaseDisplayFormPage)
271    grok.require('waeup.handleStudent')
272    icon = 'actionicon_signature.png'
273    text = _('Upload affidavit of good behavior')
274    target = 'affidavit_upload'
275
276class AffidavitDisplay(StudentFileDisplay):
277    """Affidavit of Good Behavior display viewlet.
278    """
279    grok.order(10)
280    grok.context(ICustomStudent)
281    grok.view(StudentBaseDisplayFormPage)
282    grok.require('waeup.viewStudent')
283    label = _(u'Scanned Affidavit of Good Behavior')
284    download_name = u'affidavit.pdf'
285
286class AffidavitUploadManage(StudentFileUpload):
287    """Affidavit of Good Behavior upload viewlet for officers.
288    """
289    grok.order(10)
290    grok.context(ICustomStudent)
291    grok.view(StudentBaseManageFormPage)
292    grok.require('waeup.manageStudent')
293    label = _(u'Scanned Affidavit of Good Behavior (pdf only)')
294    download_name = u'affidavit.pdf'
295
296class AffidavitUploadEdit(AffidavitUploadManage):
297    """Affidavit of Good Behavior upload viewlet for students.
298    """
299    grok.view(StudentAffidavitUploadPage)
300    grok.require('waeup.uploadStudentFile')
301
302class AffidavitGoodBehavior(StudentImage):
303    """Renders pdf slip.
304    """
305    grok.name('affidavit.pdf')
306    download_name = u'affidavit'
307
308    @property
309    def add_id(self):
310        return self.context.student_id
311
312# JAMB Letter
313
314class JAMBLetterDisplay(StudentFileDisplay):
315    """JAMB Letter display viewlet.
316    """
317    grok.order(19)
318    label = _(u'JAMB Letter')
319    title = _(u'JAMB Letter')
320    download_name = u'jamb_letter'
321
322class JAMBLetterSlip(JAMBLetterDisplay):
323    grok.view(ExportPDFClearanceSlip)
324
325class JAMBLetterUpload(StudentFileUpload):
326    """JAMB Letter upload viewlet.
327    """
328    grok.order(19)
329    label = _(u'JAMB Letter')
330    title = _(u'JAMB Letter Scan')
331    mus = 1024 * 150
332    download_name = u'jamb_letter'
333
334class JAMBLetterImage(StudentImage):
335    """Renders JAMB Letter scan.
336    """
337    grok.name('jamb_letter')
338    download_name = u'jamb_letter'
339
340# Affidavit of Non-Membership of Secret Cults
341
342class SecrCultsStatementDisplay(StudentFileDisplay):
343    """Affidavit of Non-Membership of Secret Cults display viewlet.
344    """
345    grok.order(20)
346    label = _(u'Affidavit of Non-Membership of Secret Cults')
347    title = _(u'Affidavit of Non-Membership of Secret Cults')
348    download_name = u'secr_cults'
349
350class SecrCultsStatementSlip(SecrCultsStatementDisplay):
351    grok.view(ExportPDFClearanceSlip)
352
353class SecrCultsStatementUpload(StudentFileUpload):
354    """Affidavit of Non-Membership of Secret Cults upload viewlet.
355    """
356    grok.order(20)
357    label = _(u'Affidavit of Non-Membership of Secret Cults')
358    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
359    mus = 1024 * 150
360    download_name = u'secr_cults'
361
362class SecrCultsStatementImage(StudentImage):
363    """Renders Affidavit of Non-Membership of Secret Cults scan.
364    """
365    grok.name('secr_cults')
366    download_name = u'secr_cults'
367
368# O Level Results Scratch Card
369
370class OLevelResultsScratchCardDisplay(StudentFileDisplay):
371    """O'Level Results Scratch Card display viewlet.
372    """
373    grok.order(20)
374    label = _(u'O Level Results Scratch Card')
375    title = _(u'O Level Results Scratch Card')
376    download_name = u'olevel_sc'
377
378class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
379    grok.view(ExportPDFClearanceSlip)
380
381class OLevelResultsScratchCardUpload(StudentFileUpload):
382    """O Level Results Scratch Card upload viewlet.
383    """
384    grok.order(20)
385    label = _(u'O Level Results Scratch Card')
386    title = _(u'O Level Results Scratch Card Scan')
387    mus = 1024 * 150
388    download_name = u'olevel_sc'
389
390class OLevelResultsScratchCardImage(StudentImage):
391    """Renders O Level Results Scratch Card scan.
392    """
393    grok.name('olevel_sc')
394    download_name = u'olevel_sc'
395
396# Fingerprints
397
398class LeftThumbPrintDisplay(StudentFileDisplay):
399    """Left thumb fingerprint display viewlet.
400    """
401    grok.order(21)
402    label = _(u'Left Thumb Fingerprint')
403    title = _(u'Left Thumb Fingerprint Minutiae')
404    download_name = u'finger1.fpm'
405
406class LeftThumbPrintSlip(LeftThumbPrintDisplay):
407    """Mentions scanned fingerprint on slip.
408    Fingerprint minutiae is not printed.
409    """
410    grok.view(ExportPDFClearanceSlip)
411
412class LeftThumbPrintUpload(StudentFileUpload):
413    """Left thumb fingerprint upload viewlet.
414    """
415    grok.order(21)
416    grok.require('waeup.manageStudent')
417    label = _(u'Left Thumb Fingerprint')
418    title = _(u'Left Thumb Fingerprint Minutiae')
419    mus = 1024 * 150
420    download_name = u'finger1.fpm'
421
422class LeftThumbPrintImage(StudentImage):
423    """Renders left thumb fingerprint minutiae for download.
424    """
425    grok.name('finger1.fpm')
426    download_name = u'finger1.fpm'
427
428# Original JAMB picture
429
430class JAMBPictureDisplay(PassportDisplay):
431    """Original JAMB picture display viewlet.
432    """
433    grok.order(22)
434    label = _(u'Original JAMB Picture')
435    title = _(u'Original JAMB Picture')
436    download_name = u'passport2'
437
438class JAMBPictureSlip(JAMBPictureDisplay):
439    grok.view(ExportPDFClearanceSlip)
440
441class JAMBPictureUpload(StudentFileUpload):
442    """Original JAMB picture upload viewlet.
443    """
444    grok.order(22)
445    grok.require('waeup.manageStudent')
446    label = _(u'Original JAMB Picture')
447    title = _(u'Original JAMB Picture')
448    mus = 1024 * 150
449    download_name = u'passport2'
450
451class JAMBPictureImage(StudentImage):
452    """Renders Original JAMB picture.
453    """
454    grok.name('passport2')
455    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.