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

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

Change slip name.

  • Property svn:keywords set to Id
File size: 15.0 KB
RevLine 
[9382]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
[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
[17904]36from waeup.kofa.students.fileviewlets import FinalClearance
37
[16361]38from waeup.uniben.students.interfaces import (
39    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
[16808]40    ICustomStudent, ICustomStudentOnlinePayment)
[16361]41
[17880]42from waeup.uniben.students.browser import (
[17885]43    StudentMedicalHistoryEditFormPage, StudentAffidavitUploadPage,
44    StudentAffidavitUploadPage)
[16382]45
[9382]46from kofacustom.nigeria.interfaces import MessageFactory as _
47
[16449]48class RequestTranscriptActionButton(RequestTranscriptActionButton):
[16130]49
50    @property
51    def target_url(self):
52        return ''
53
[16906]54class TranscriptSlipActionButton(TranscriptSlipActionButton):
55    grok.require('waeup.viewStudent')
56
57class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
58    grok.require('waeup.viewStudent')
59
[16361]60
[15371]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
[9439]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'
[9382]77
[9439]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
[12855]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
[9848]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
[12121]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
[12122]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
[12121]132
[17542]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
[13723]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'
[12122]157
[13723]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
[15352]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):
[15371]176        if self.context.library:
177            return self.view.url(self.view.context, self.target)
178        return
[15352]179
[14834]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):
[14902]191        if self.context.flash_notice and self.context.is_jupeb \
[14835]192            and 'results' in self.context.flash_notice.lower():
[14834]193            return self.view.url(self.view.context, self.target)
194        return False
195
[16383]196class MedicalHistoryEditActionButton(ManageActionButton):
[16382]197    grok.order(12)
198    grok.context(ICustomStudent)
199    grok.view(StudentBaseDisplayFormPage)
200    grok.require('waeup.handleStudent')
[16385]201    text = _('Medical Questionnaire')
[16382]202    target = 'edit_medical'
203    icon = 'actionicon_medical.png'
204
[16383]205class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
206    grok.require('waeup.manageStudent')
207    text = _('Manage medical history')
208    target = 'manage_medical'
209
[16382]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'
[16385]216    text = _('Download medical questionnaire slip')
217    target = 'medical_questionnaire_slip.pdf'
[16382]218
[17255]219class TishipSlipActionButton(ManageActionButton):
220    grok.order(2)
221    grok.context(ICustomStudent)
[17395]222    grok.view(StudentBaseDisplayFormPage)
[17255]223    grok.require('waeup.viewStudent')
224    icon = 'actionicon_pdf.png'
225    text = _('Download TISHIP registration slip')
226    target = 'tiship_slip.pdf'
227
[16808]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
[17822]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
[17881]268# Affidavit of Good Behavior
269
[17880]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'
[17885]276    text = _('Upload affidavit of good conduct')
[17880]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')
[17885]286    label = _(u'Scanned Affidavit of Good Conduct')
[17880]287    download_name = u'affidavit.pdf'
288
[17885]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
[17880]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')
[17885]305    label = _(u'Scanned Affidavit of Good Conduct (pdf only)')
[17880]306    download_name = u'affidavit.pdf'
307
308class AffidavitUploadEdit(AffidavitUploadManage):
[17885]309    """Affidavit of Good Conduct upload viewlet for students.
[17880]310    """
311    grok.view(StudentAffidavitUploadPage)
312    grok.require('waeup.uploadStudentFile')
313
[17885]314class AffidavitGoodConduct(StudentImage):
[17880]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
[17904]324class CustomnFinalClearance(FinalClearance):
325    """Renders pdf slip.
326    """
327    @property
328    def add_id(self):
329        return self.context.matric_number
330
[9382]331# JAMB Letter
332
[12452]333class JAMBLetterDisplay(StudentFileDisplay):
[9382]334    """JAMB Letter display viewlet.
335    """
336    grok.order(19)
337    label = _(u'JAMB Letter')
338    title = _(u'JAMB Letter')
[11556]339    download_name = u'jamb_letter'
[9382]340
341class JAMBLetterSlip(JAMBLetterDisplay):
[13063]342    grok.view(ExportPDFClearanceSlip)
[9382]343
[12452]344class JAMBLetterUpload(StudentFileUpload):
[9382]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
[11556]351    download_name = u'jamb_letter'
[9382]352
[12452]353class JAMBLetterImage(StudentImage):
[9382]354    """Renders JAMB Letter scan.
355    """
[11556]356    grok.name('jamb_letter')
357    download_name = u'jamb_letter'
[9382]358
359# Affidavit of Non-Membership of Secret Cults
360
[12452]361class SecrCultsStatementDisplay(StudentFileDisplay):
[9382]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):
[13063]370    grok.view(ExportPDFClearanceSlip)
[9382]371
[12452]372class SecrCultsStatementUpload(StudentFileUpload):
[9382]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
[12452]381class SecrCultsStatementImage(StudentImage):
[9382]382    """Renders Affidavit of Non-Membership of Secret Cults scan.
383    """
384    grok.name('secr_cults')
[11611]385    download_name = u'secr_cults'
386
[16364]387# O Level Results Scratch Card
[16359]388
[16364]389class OLevelResultsScratchCardDisplay(StudentFileDisplay):
390    """O'Level Results Scratch Card display viewlet.
[16359]391    """
392    grok.order(20)
[16364]393    label = _(u'O Level Results Scratch Card')
394    title = _(u'O Level Results Scratch Card')
395    download_name = u'olevel_sc'
[16359]396
[16364]397class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
[16359]398    grok.view(ExportPDFClearanceSlip)
399
[16364]400class OLevelResultsScratchCardUpload(StudentFileUpload):
401    """O Level Results Scratch Card upload viewlet.
[16359]402    """
403    grok.order(20)
[16364]404    label = _(u'O Level Results Scratch Card')
405    title = _(u'O Level Results Scratch Card Scan')
[16359]406    mus = 1024 * 150
[16364]407    download_name = u'olevel_sc'
[16359]408
[16364]409class OLevelResultsScratchCardImage(StudentImage):
410    """Renders O Level Results Scratch Card scan.
[16359]411    """
[16364]412    grok.name('olevel_sc')
413    download_name = u'olevel_sc'
[16359]414
[11611]415# Fingerprints
416
[12452]417class LeftThumbPrintDisplay(StudentFileDisplay):
[11611]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.
[16443]427    Fingerprint minutiae is not printed.
[11611]428    """
[13063]429    grok.view(ExportPDFClearanceSlip)
[11611]430
[12452]431class LeftThumbPrintUpload(StudentFileUpload):
[11611]432    """Left thumb fingerprint upload viewlet.
433    """
434    grok.order(21)
[11613]435    grok.require('waeup.manageStudent')
[11611]436    label = _(u'Left Thumb Fingerprint')
437    title = _(u'Left Thumb Fingerprint Minutiae')
[16363]438    mus = 1024 * 150
[11611]439    download_name = u'finger1.fpm'
440
[12452]441class LeftThumbPrintImage(StudentImage):
[11611]442    """Renders left thumb fingerprint minutiae for download.
443    """
444    grok.name('finger1.fpm')
[16423]445    download_name = u'finger1.fpm'
446
[16473]447# Original JAMB picture
[16423]448
[16441]449class JAMBPictureDisplay(PassportDisplay):
[16423]450    """Original JAMB picture display viewlet.
451    """
[16473]452    grok.order(22)
[16423]453    label = _(u'Original JAMB Picture')
454    title = _(u'Original JAMB Picture')
[16443]455    download_name = u'passport2'
[16423]456
457class JAMBPictureSlip(JAMBPictureDisplay):
458    grok.view(ExportPDFClearanceSlip)
459
[16473]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
[16423]470class JAMBPictureImage(StudentImage):
471    """Renders Original JAMB picture.
472    """
[16443]473    grok.name('passport2')
474    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.