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

Last change on this file since 17384 was 17255, checked in by Henrik Bettermann, 23 months ago

Add ExportPDFTishipSlip.

  • Property svn:keywords set to Id
File size: 12.1 KB
RevLine 
[9382]1## $Id: viewlets.py 17255 2023-01-03 17:40:18Z 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
21from waeup.kofa.interfaces import REQUESTED, REGISTERED, 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,
[16808]29    StudentBaseDisplayFormPage, OnlinePaymentDisplayFormPage)
[16361]30from waeup.kofa.students.viewlets import (
[16906]31    RequestTranscriptActionButton, StudentPassportActionButton,
32    TranscriptSlipActionButton,
33    StudyCourseTranscriptActionButton)
[9382]34
[16361]35from waeup.uniben.students.interfaces import (
36    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
[16808]37    ICustomStudent, ICustomStudentOnlinePayment)
[16361]38
[16382]39from waeup.uniben.students.browser import StudentMedicalHistoryEditFormPage
40
[9382]41from kofacustom.nigeria.interfaces import MessageFactory as _
42
[16449]43class RequestTranscriptActionButton(RequestTranscriptActionButton):
[16130]44
45    @property
46    def target_url(self):
47        return ''
48
[16906]49class TranscriptSlipActionButton(TranscriptSlipActionButton):
50    grok.require('waeup.viewStudent')
51
52class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
53    grok.require('waeup.viewStudent')
54
[16449]55class StudentPassportActionButton(StudentPassportActionButton):
[16361]56
57    @property
58    def target_url(self):
[17125]59        if self.context.is_jupeb:
[17145]60            return ''
[16361]61        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
[17142]62        if self.context.state not in PORTRAIT_CHANGE_STATES and not self.context.is_postgrad:
[16361]63            return ''
64        return self.view.url(self.view.context, self.target)
65
[15371]66class SwitchLibraryAccessActionButton(ManageActionButton):
67    grok.order(7)
68    grok.context(ICustomStudent)
69    grok.view(StudentBaseDisplayFormPage)
70    grok.require('waeup.switchLibraryAccess')
71    text = _('Switch library access')
72    target = 'switch_library_access'
73    icon = 'actionicon_book.png'
74
[9439]75class StudyCourseEditActionButton(ManageActionButton):
76    grok.order(1)
77    grok.context(ICustomStudentStudyCourse)
78    grok.view(StudyCourseDisplayFormPage)
79    grok.require('waeup.clearStudent')
80    text = _('Edit level')
81    target = 'edit_level'
[9382]82
[9439]83    @property
84    def target_url(self):
85        if self.context.is_current and self.context.student.state == REQUESTED:
86            return self.view.url(self.view.context, self.target)
87        return False
88
[12855]89class CourseRegistrationSlipActionButton(ManageActionButton):
90    grok.order(5)
91    grok.context(ICustomStudentStudyLevel)
92    grok.view(StudyLevelDisplayFormPage)
93    grok.require('waeup.viewStudent')
94    icon = 'actionicon_pdf.png'
95    text = _('Download course registration slip')
96    target = 'course_registration_slip.pdf'
97
98    @property
99    def target_url(self):
100        is_current = self.context.__parent__.is_current
101        if not is_current:
102            return ''
103        if self.context.student.state != REGISTERED \
104            or self.context.student.current_level != self.context.level:
105            return ''
106        return self.view.url(self.view.context, self.target)
107
[9848]108class CourseResultSlipActionButton(ManageActionButton):
109    grok.order(6)
110    grok.context(ICustomStudentStudyLevel)
111    grok.view(StudyLevelDisplayFormPage)
112    grok.require('waeup.viewStudent')
113    icon = 'actionicon_pdf.png'
114    text = _('Download course result slip')
115    target = 'course_result_slip.pdf'
116
117    @property
118    def target_url(self):
119        return self.view.url(self.view.context, self.target)
120
[12121]121
122class ClearanceInvitationSlipActionButton(ManageActionButton):
123    grok.order(5)
124    grok.context(ICustomStudent)
125    grok.view(StudentClearanceDisplayFormPage)
126    grok.require('waeup.viewStudent')
127    icon = 'actionicon_pdf.png'
128    text = _('Download clearance invitation slip')
129    target = 'clearance_invitation_slip.pdf'
130
[12122]131    @property
132    def target_url(self):
133        if self.context.student.state == REQUESTED \
134            and self.context.student.physical_clearance_date:
135            return self.view.url(self.view.context, self.target)
136        return False
[12121]137
[13723]138class ExaminationScheduleSlipActionButton(ManageActionButton):
139    grok.order(10)
140    grok.context(ICustomStudent)
141    grok.view(StudentBaseDisplayFormPage)
142    grok.require('waeup.viewStudent')
143    icon = 'actionicon_pdf.png'
144    text = _('Download examination schedule slip')
145    target = 'examination_schedule_slip.pdf'
[12122]146
[13723]147    @property
148    def target_url(self):
149        if self.context.flash_notice \
150            and 'exam' in self.context.flash_notice.lower():
151            return self.view.url(self.view.context, self.target)
152        return False
153
[15352]154class JHLIdCardActionButton(ManageActionButton):
155    grok.order(10)
156    grok.context(ICustomStudent)
157    grok.view(StudentBaseDisplayFormPage)
158    grok.require('waeup.viewStudent')
159    icon = 'actionicon_pdf.png'
160    text = _('Download JHL Id Card')
161    target = 'jhl_idcard.pdf'
162
163    @property
164    def target_url(self):
[15371]165        if self.context.library:
166            return self.view.url(self.view.context, self.target)
167        return
[15352]168
[14834]169class JUPEBResultSlipActionButton(ManageActionButton):
170    grok.order(11)
171    grok.context(ICustomStudent)
172    grok.view(StudentBaseDisplayFormPage)
173    grok.require('waeup.viewStudent')
174    icon = 'actionicon_pdf.png'
175    text = _('Download JUPEB result slip')
176    target = 'jupeb_result_slip.pdf'
177
178    @property
179    def target_url(self):
[14902]180        if self.context.flash_notice and self.context.is_jupeb \
[14835]181            and 'results' in self.context.flash_notice.lower():
[14834]182            return self.view.url(self.view.context, self.target)
183        return False
184
[16383]185class MedicalHistoryEditActionButton(ManageActionButton):
[16382]186    grok.order(12)
187    grok.context(ICustomStudent)
188    grok.view(StudentBaseDisplayFormPage)
189    grok.require('waeup.handleStudent')
[16385]190    text = _('Medical Questionnaire')
[16382]191    target = 'edit_medical'
192    icon = 'actionicon_medical.png'
193
[16383]194class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
195    grok.require('waeup.manageStudent')
196    text = _('Manage medical history')
197    target = 'manage_medical'
198
[16382]199class MedicalHistorySlipActionButton(ManageActionButton):
200    grok.order(1)
201    grok.context(ICustomStudent)
202    grok.view(StudentMedicalHistoryEditFormPage)
203    grok.require('waeup.viewStudent')
204    icon = 'actionicon_pdf.png'
[16385]205    text = _('Download medical questionnaire slip')
206    target = 'medical_questionnaire_slip.pdf'
[16382]207
[17255]208class TishipSlipActionButton(ManageActionButton):
209    grok.order(2)
210    grok.context(ICustomStudent)
211    grok.view(StudentMedicalHistoryEditFormPage)
212    grok.require('waeup.viewStudent')
213    icon = 'actionicon_pdf.png'
214    text = _('Download TISHIP registration slip')
215    target = 'tiship_slip.pdf'
216
[16808]217class PlagTestLinkActionButton(ManageActionButton):
218    grok.order(10) 
219    grok.context(ICustomStudentOnlinePayment)
220    grok.view(OnlinePaymentDisplayFormPage)
221    grok.require('waeup.viewStudent')
222    icon = 'actionicon_up.png'
223    text = _('Upload project/thesis file')
224    target = 'plagtestinfo'
225
226    @property
227    def target_url(self):
228        if self.context.p_state != 'paid' \
229            or self.context.p_category != 'plag_test':
230            return ''
231        return self.view.url(self.view.context, self.target)
232
[9382]233# JAMB Letter
234
[12452]235class JAMBLetterDisplay(StudentFileDisplay):
[9382]236    """JAMB Letter display viewlet.
237    """
238    grok.order(19)
239    label = _(u'JAMB Letter')
240    title = _(u'JAMB Letter')
[11556]241    download_name = u'jamb_letter'
[9382]242
243class JAMBLetterSlip(JAMBLetterDisplay):
[13063]244    grok.view(ExportPDFClearanceSlip)
[9382]245
[12452]246class JAMBLetterUpload(StudentFileUpload):
[9382]247    """JAMB Letter upload viewlet.
248    """
249    grok.order(19)
250    label = _(u'JAMB Letter')
251    title = _(u'JAMB Letter Scan')
252    mus = 1024 * 150
[11556]253    download_name = u'jamb_letter'
[9382]254
[12452]255class JAMBLetterImage(StudentImage):
[9382]256    """Renders JAMB Letter scan.
257    """
[11556]258    grok.name('jamb_letter')
259    download_name = u'jamb_letter'
[9382]260
261# Affidavit of Non-Membership of Secret Cults
262
[12452]263class SecrCultsStatementDisplay(StudentFileDisplay):
[9382]264    """Affidavit of Non-Membership of Secret Cults display viewlet.
265    """
266    grok.order(20)
267    label = _(u'Affidavit of Non-Membership of Secret Cults')
268    title = _(u'Affidavit of Non-Membership of Secret Cults')
269    download_name = u'secr_cults'
270
271class SecrCultsStatementSlip(SecrCultsStatementDisplay):
[13063]272    grok.view(ExportPDFClearanceSlip)
[9382]273
[12452]274class SecrCultsStatementUpload(StudentFileUpload):
[9382]275    """Affidavit of Non-Membership of Secret Cults upload viewlet.
276    """
277    grok.order(20)
278    label = _(u'Affidavit of Non-Membership of Secret Cults')
279    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
280    mus = 1024 * 150
281    download_name = u'secr_cults'
282
[12452]283class SecrCultsStatementImage(StudentImage):
[9382]284    """Renders Affidavit of Non-Membership of Secret Cults scan.
285    """
286    grok.name('secr_cults')
[11611]287    download_name = u'secr_cults'
288
[16364]289# O Level Results Scratch Card
[16359]290
[16364]291class OLevelResultsScratchCardDisplay(StudentFileDisplay):
292    """O'Level Results Scratch Card display viewlet.
[16359]293    """
294    grok.order(20)
[16364]295    label = _(u'O Level Results Scratch Card')
296    title = _(u'O Level Results Scratch Card')
297    download_name = u'olevel_sc'
[16359]298
[16364]299class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
[16359]300    grok.view(ExportPDFClearanceSlip)
301
[16364]302class OLevelResultsScratchCardUpload(StudentFileUpload):
303    """O Level Results Scratch Card upload viewlet.
[16359]304    """
305    grok.order(20)
[16364]306    label = _(u'O Level Results Scratch Card')
307    title = _(u'O Level Results Scratch Card Scan')
[16359]308    mus = 1024 * 150
[16364]309    download_name = u'olevel_sc'
[16359]310
[16364]311class OLevelResultsScratchCardImage(StudentImage):
312    """Renders O Level Results Scratch Card scan.
[16359]313    """
[16364]314    grok.name('olevel_sc')
315    download_name = u'olevel_sc'
[16359]316
[11611]317# Fingerprints
318
[12452]319class LeftThumbPrintDisplay(StudentFileDisplay):
[11611]320    """Left thumb fingerprint display viewlet.
321    """
322    grok.order(21)
323    label = _(u'Left Thumb Fingerprint')
324    title = _(u'Left Thumb Fingerprint Minutiae')
325    download_name = u'finger1.fpm'
326
327class LeftThumbPrintSlip(LeftThumbPrintDisplay):
328    """Mentions scanned fingerprint on slip.
[16443]329    Fingerprint minutiae is not printed.
[11611]330    """
[13063]331    grok.view(ExportPDFClearanceSlip)
[11611]332
[12452]333class LeftThumbPrintUpload(StudentFileUpload):
[11611]334    """Left thumb fingerprint upload viewlet.
335    """
336    grok.order(21)
[11613]337    grok.require('waeup.manageStudent')
[11611]338    label = _(u'Left Thumb Fingerprint')
339    title = _(u'Left Thumb Fingerprint Minutiae')
[16363]340    mus = 1024 * 150
[11611]341    download_name = u'finger1.fpm'
342
[12452]343class LeftThumbPrintImage(StudentImage):
[11611]344    """Renders left thumb fingerprint minutiae for download.
345    """
346    grok.name('finger1.fpm')
[16423]347    download_name = u'finger1.fpm'
348
[16473]349# Original JAMB picture
[16423]350
[16441]351class JAMBPictureDisplay(PassportDisplay):
[16423]352    """Original JAMB picture display viewlet.
353    """
[16473]354    grok.order(22)
[16423]355    label = _(u'Original JAMB Picture')
356    title = _(u'Original JAMB Picture')
[16443]357    download_name = u'passport2'
[16423]358
359class JAMBPictureSlip(JAMBPictureDisplay):
360    grok.view(ExportPDFClearanceSlip)
361
[16473]362class JAMBPictureUpload(StudentFileUpload):
363    """Original JAMB picture upload viewlet.
364    """
365    grok.order(22)
366    grok.require('waeup.manageStudent')
367    label = _(u'Original JAMB Picture')
368    title = _(u'Original JAMB Picture')
369    mus = 1024 * 150
370    download_name = u'passport2'
371
[16423]372class JAMBPictureImage(StudentImage):
373    """Renders Original JAMB picture.
374    """
[16443]375    grok.name('passport2')
376    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.