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

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

Add affidavit of good behavior upload components.

  • Property svn:keywords set to Id
File size: 14.4 KB
Line 
1## $Id: viewlets.py 17880 2024-08-10 21:19:24Z 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
265class StudentAffidavitUploadActionButton(ManageActionButton):
266    grok.order(14)
267    grok.context(ICustomStudent)
268    grok.view(StudentBaseDisplayFormPage)
269    grok.require('waeup.handleStudent')
270    icon = 'actionicon_signature.png'
271    text = _('Upload affidavit of good behavior')
272    target = 'affidavit_upload'
273
274class AffidavitDisplay(StudentFileDisplay):
275    """Affidavit of Good Behavior display viewlet.
276    """
277    grok.order(10)
278    grok.context(ICustomStudent)
279    grok.view(StudentBaseDisplayFormPage)
280    grok.require('waeup.viewStudent')
281    label = _(u'Scanned Affidavit of Good Behavior')
282    download_name = u'affidavit.pdf'
283
284class AffidavitUploadManage(StudentFileUpload):
285    """Affidavit of Good Behavior upload viewlet for officers.
286    """
287    grok.order(10)
288    grok.context(ICustomStudent)
289    grok.view(StudentBaseManageFormPage)
290    grok.require('waeup.manageStudent')
291    label = _(u'Scanned Affidavit of Good Behavior (pdf only)')
292    download_name = u'affidavit.pdf'
293
294class AffidavitUploadEdit(AffidavitUploadManage):
295    """Affidavit of Good Behavior upload viewlet for students.
296    """
297    grok.view(StudentAffidavitUploadPage)
298    grok.require('waeup.uploadStudentFile')
299
300class FinalClearance(StudentImage):
301    """Renders pdf slip.
302    """
303    grok.name('affidavit.pdf')
304    download_name = u'affidavit'
305
306    @property
307    def add_id(self):
308        return self.context.student_id
309
310# JAMB Letter
311
312class JAMBLetterDisplay(StudentFileDisplay):
313    """JAMB Letter display viewlet.
314    """
315    grok.order(19)
316    label = _(u'JAMB Letter')
317    title = _(u'JAMB Letter')
318    download_name = u'jamb_letter'
319
320class JAMBLetterSlip(JAMBLetterDisplay):
321    grok.view(ExportPDFClearanceSlip)
322
323class JAMBLetterUpload(StudentFileUpload):
324    """JAMB Letter upload viewlet.
325    """
326    grok.order(19)
327    label = _(u'JAMB Letter')
328    title = _(u'JAMB Letter Scan')
329    mus = 1024 * 150
330    download_name = u'jamb_letter'
331
332class JAMBLetterImage(StudentImage):
333    """Renders JAMB Letter scan.
334    """
335    grok.name('jamb_letter')
336    download_name = u'jamb_letter'
337
338# Affidavit of Non-Membership of Secret Cults
339
340class SecrCultsStatementDisplay(StudentFileDisplay):
341    """Affidavit of Non-Membership of Secret Cults display viewlet.
342    """
343    grok.order(20)
344    label = _(u'Affidavit of Non-Membership of Secret Cults')
345    title = _(u'Affidavit of Non-Membership of Secret Cults')
346    download_name = u'secr_cults'
347
348class SecrCultsStatementSlip(SecrCultsStatementDisplay):
349    grok.view(ExportPDFClearanceSlip)
350
351class SecrCultsStatementUpload(StudentFileUpload):
352    """Affidavit of Non-Membership of Secret Cults upload viewlet.
353    """
354    grok.order(20)
355    label = _(u'Affidavit of Non-Membership of Secret Cults')
356    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
357    mus = 1024 * 150
358    download_name = u'secr_cults'
359
360class SecrCultsStatementImage(StudentImage):
361    """Renders Affidavit of Non-Membership of Secret Cults scan.
362    """
363    grok.name('secr_cults')
364    download_name = u'secr_cults'
365
366# O Level Results Scratch Card
367
368class OLevelResultsScratchCardDisplay(StudentFileDisplay):
369    """O'Level Results Scratch Card display viewlet.
370    """
371    grok.order(20)
372    label = _(u'O Level Results Scratch Card')
373    title = _(u'O Level Results Scratch Card')
374    download_name = u'olevel_sc'
375
376class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
377    grok.view(ExportPDFClearanceSlip)
378
379class OLevelResultsScratchCardUpload(StudentFileUpload):
380    """O Level Results Scratch Card upload viewlet.
381    """
382    grok.order(20)
383    label = _(u'O Level Results Scratch Card')
384    title = _(u'O Level Results Scratch Card Scan')
385    mus = 1024 * 150
386    download_name = u'olevel_sc'
387
388class OLevelResultsScratchCardImage(StudentImage):
389    """Renders O Level Results Scratch Card scan.
390    """
391    grok.name('olevel_sc')
392    download_name = u'olevel_sc'
393
394# Fingerprints
395
396class LeftThumbPrintDisplay(StudentFileDisplay):
397    """Left thumb fingerprint display viewlet.
398    """
399    grok.order(21)
400    label = _(u'Left Thumb Fingerprint')
401    title = _(u'Left Thumb Fingerprint Minutiae')
402    download_name = u'finger1.fpm'
403
404class LeftThumbPrintSlip(LeftThumbPrintDisplay):
405    """Mentions scanned fingerprint on slip.
406    Fingerprint minutiae is not printed.
407    """
408    grok.view(ExportPDFClearanceSlip)
409
410class LeftThumbPrintUpload(StudentFileUpload):
411    """Left thumb fingerprint upload viewlet.
412    """
413    grok.order(21)
414    grok.require('waeup.manageStudent')
415    label = _(u'Left Thumb Fingerprint')
416    title = _(u'Left Thumb Fingerprint Minutiae')
417    mus = 1024 * 150
418    download_name = u'finger1.fpm'
419
420class LeftThumbPrintImage(StudentImage):
421    """Renders left thumb fingerprint minutiae for download.
422    """
423    grok.name('finger1.fpm')
424    download_name = u'finger1.fpm'
425
426# Original JAMB picture
427
428class JAMBPictureDisplay(PassportDisplay):
429    """Original JAMB picture display viewlet.
430    """
431    grok.order(22)
432    label = _(u'Original JAMB Picture')
433    title = _(u'Original JAMB Picture')
434    download_name = u'passport2'
435
436class JAMBPictureSlip(JAMBPictureDisplay):
437    grok.view(ExportPDFClearanceSlip)
438
439class JAMBPictureUpload(StudentFileUpload):
440    """Original JAMB picture upload viewlet.
441    """
442    grok.order(22)
443    grok.require('waeup.manageStudent')
444    label = _(u'Original JAMB Picture')
445    title = _(u'Original JAMB Picture')
446    mus = 1024 * 150
447    download_name = u'passport2'
448
449class JAMBPictureImage(StudentImage):
450    """Renders Original JAMB picture.
451    """
452    grok.name('passport2')
453    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.