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

Last change on this file since 17885 was 17885, checked in by Henrik Bettermann, 6 weeks ago

Provide affidavit of good conduct form.

  • Property svn:keywords set to Id
File size: 14.8 KB
RevLine 
[9382]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
[16361]20from zope.component import getUtility
[17542]21from waeup.kofa.interfaces import REQUESTED, REGISTERED, CLEARED, IExtFileStore
[9439]22from waeup.kofa.browser.viewlets import ManageActionButton
[16361]23from waeup.kofa.students.interfaces import IStudentsUtils
[12423]24from waeup.kofa.students.fileviewlets import (
[16441]25    StudentFileDisplay, StudentFileUpload, StudentImage, PassportDisplay)
[9439]26from waeup.kofa.students.browser import (
[13063]27    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
[13723]28    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
[17880]29    StudentBaseDisplayFormPage, StudentBaseManageFormPage,
30    OnlinePaymentDisplayFormPage)
[16361]31from waeup.kofa.students.viewlets import (
[17812]32    RequestTranscriptActionButton,
[16906]33    TranscriptSlipActionButton,
34    StudyCourseTranscriptActionButton)
[9382]35
[16361]36from waeup.uniben.students.interfaces import (
37    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
[16808]38    ICustomStudent, ICustomStudentOnlinePayment)
[16361]39
[17880]40from waeup.uniben.students.browser import (
[17885]41    StudentMedicalHistoryEditFormPage, StudentAffidavitUploadPage,
42    StudentAffidavitUploadPage)
[16382]43
[9382]44from kofacustom.nigeria.interfaces import MessageFactory as _
45
[16449]46class RequestTranscriptActionButton(RequestTranscriptActionButton):
[16130]47
48    @property
49    def target_url(self):
50        return ''
51
[16906]52class TranscriptSlipActionButton(TranscriptSlipActionButton):
53    grok.require('waeup.viewStudent')
54
55class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
56    grok.require('waeup.viewStudent')
57
[16361]58
[15371]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
[9439]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'
[9382]75
[9439]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
[12855]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
[9848]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
[12121]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
[12122]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
[12121]130
[17542]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
[13723]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'
[12122]155
[13723]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
[15352]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):
[15371]174        if self.context.library:
175            return self.view.url(self.view.context, self.target)
176        return
[15352]177
[14834]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):
[14902]189        if self.context.flash_notice and self.context.is_jupeb \
[14835]190            and 'results' in self.context.flash_notice.lower():
[14834]191            return self.view.url(self.view.context, self.target)
192        return False
193
[16383]194class MedicalHistoryEditActionButton(ManageActionButton):
[16382]195    grok.order(12)
196    grok.context(ICustomStudent)
197    grok.view(StudentBaseDisplayFormPage)
198    grok.require('waeup.handleStudent')
[16385]199    text = _('Medical Questionnaire')
[16382]200    target = 'edit_medical'
201    icon = 'actionicon_medical.png'
202
[16383]203class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
204    grok.require('waeup.manageStudent')
205    text = _('Manage medical history')
206    target = 'manage_medical'
207
[16382]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'
[16385]214    text = _('Download medical questionnaire slip')
215    target = 'medical_questionnaire_slip.pdf'
[16382]216
[17255]217class TishipSlipActionButton(ManageActionButton):
218    grok.order(2)
219    grok.context(ICustomStudent)
[17395]220    grok.view(StudentBaseDisplayFormPage)
[17255]221    grok.require('waeup.viewStudent')
222    icon = 'actionicon_pdf.png'
223    text = _('Download TISHIP registration slip')
224    target = 'tiship_slip.pdf'
225
[16808]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
[17822]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
[17881]266# Affidavit of Good Behavior
267
[17880]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'
[17885]274    text = _('Upload affidavit of good conduct')
[17880]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')
[17885]284    label = _(u'Scanned Affidavit of Good Conduct')
[17880]285    download_name = u'affidavit.pdf'
286
[17885]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
[17880]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')
[17885]303    label = _(u'Scanned Affidavit of Good Conduct (pdf only)')
[17880]304    download_name = u'affidavit.pdf'
305
306class AffidavitUploadEdit(AffidavitUploadManage):
[17885]307    """Affidavit of Good Conduct upload viewlet for students.
[17880]308    """
309    grok.view(StudentAffidavitUploadPage)
310    grok.require('waeup.uploadStudentFile')
311
[17885]312class AffidavitGoodConduct(StudentImage):
[17880]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
[9382]322# JAMB Letter
323
[12452]324class JAMBLetterDisplay(StudentFileDisplay):
[9382]325    """JAMB Letter display viewlet.
326    """
327    grok.order(19)
328    label = _(u'JAMB Letter')
329    title = _(u'JAMB Letter')
[11556]330    download_name = u'jamb_letter'
[9382]331
332class JAMBLetterSlip(JAMBLetterDisplay):
[13063]333    grok.view(ExportPDFClearanceSlip)
[9382]334
[12452]335class JAMBLetterUpload(StudentFileUpload):
[9382]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
[11556]342    download_name = u'jamb_letter'
[9382]343
[12452]344class JAMBLetterImage(StudentImage):
[9382]345    """Renders JAMB Letter scan.
346    """
[11556]347    grok.name('jamb_letter')
348    download_name = u'jamb_letter'
[9382]349
350# Affidavit of Non-Membership of Secret Cults
351
[12452]352class SecrCultsStatementDisplay(StudentFileDisplay):
[9382]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):
[13063]361    grok.view(ExportPDFClearanceSlip)
[9382]362
[12452]363class SecrCultsStatementUpload(StudentFileUpload):
[9382]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
[12452]372class SecrCultsStatementImage(StudentImage):
[9382]373    """Renders Affidavit of Non-Membership of Secret Cults scan.
374    """
375    grok.name('secr_cults')
[11611]376    download_name = u'secr_cults'
377
[16364]378# O Level Results Scratch Card
[16359]379
[16364]380class OLevelResultsScratchCardDisplay(StudentFileDisplay):
381    """O'Level Results Scratch Card display viewlet.
[16359]382    """
383    grok.order(20)
[16364]384    label = _(u'O Level Results Scratch Card')
385    title = _(u'O Level Results Scratch Card')
386    download_name = u'olevel_sc'
[16359]387
[16364]388class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
[16359]389    grok.view(ExportPDFClearanceSlip)
390
[16364]391class OLevelResultsScratchCardUpload(StudentFileUpload):
392    """O Level Results Scratch Card upload viewlet.
[16359]393    """
394    grok.order(20)
[16364]395    label = _(u'O Level Results Scratch Card')
396    title = _(u'O Level Results Scratch Card Scan')
[16359]397    mus = 1024 * 150
[16364]398    download_name = u'olevel_sc'
[16359]399
[16364]400class OLevelResultsScratchCardImage(StudentImage):
401    """Renders O Level Results Scratch Card scan.
[16359]402    """
[16364]403    grok.name('olevel_sc')
404    download_name = u'olevel_sc'
[16359]405
[11611]406# Fingerprints
407
[12452]408class LeftThumbPrintDisplay(StudentFileDisplay):
[11611]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.
[16443]418    Fingerprint minutiae is not printed.
[11611]419    """
[13063]420    grok.view(ExportPDFClearanceSlip)
[11611]421
[12452]422class LeftThumbPrintUpload(StudentFileUpload):
[11611]423    """Left thumb fingerprint upload viewlet.
424    """
425    grok.order(21)
[11613]426    grok.require('waeup.manageStudent')
[11611]427    label = _(u'Left Thumb Fingerprint')
428    title = _(u'Left Thumb Fingerprint Minutiae')
[16363]429    mus = 1024 * 150
[11611]430    download_name = u'finger1.fpm'
431
[12452]432class LeftThumbPrintImage(StudentImage):
[11611]433    """Renders left thumb fingerprint minutiae for download.
434    """
435    grok.name('finger1.fpm')
[16423]436    download_name = u'finger1.fpm'
437
[16473]438# Original JAMB picture
[16423]439
[16441]440class JAMBPictureDisplay(PassportDisplay):
[16423]441    """Original JAMB picture display viewlet.
442    """
[16473]443    grok.order(22)
[16423]444    label = _(u'Original JAMB Picture')
445    title = _(u'Original JAMB Picture')
[16443]446    download_name = u'passport2'
[16423]447
448class JAMBPictureSlip(JAMBPictureDisplay):
449    grok.view(ExportPDFClearanceSlip)
450
[16473]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
[16423]461class JAMBPictureImage(StudentImage):
462    """Renders Original JAMB picture.
463    """
[16443]464    grok.name('passport2')
465    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.