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

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

Change slip name.

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