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

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

Provide affidavit of good conduct form.

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