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

Last change on this file since 17718 was 17542, checked in by Henrik Bettermann, 15 months ago

Implement medical examination form.

  • Property svn:keywords set to Id
File size: 12.7 KB
RevLine 
[9382]1## $Id: viewlets.py 17542 2023-08-16 09:24:29Z 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,
[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
[17542]138class MadicalExaminationSlipActionButton(ManageActionButton):
139    grok.order(6)
140    grok.context(ICustomStudent)
141    grok.view(StudentClearanceDisplayFormPage)
142    grok.require('waeup.viewStudent')
143    icon = 'actionicon_pdf.png'
144    text = _('Download medical examination slip')
145    target = 'medical_examination_slip.pdf'
146
147    @property
148    def target_url(self):
149        if self.context.student.state == CLEARED \
150            and self.context.student.physical_clearance_date:
151            return self.view.url(self.view.context, self.target)
152        return False
153
[13723]154class ExaminationScheduleSlipActionButton(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 examination schedule slip')
161    target = 'examination_schedule_slip.pdf'
[12122]162
[13723]163    @property
164    def target_url(self):
165        if self.context.flash_notice \
166            and 'exam' in self.context.flash_notice.lower():
167            return self.view.url(self.view.context, self.target)
168        return False
169
[15352]170class JHLIdCardActionButton(ManageActionButton):
171    grok.order(10)
172    grok.context(ICustomStudent)
173    grok.view(StudentBaseDisplayFormPage)
174    grok.require('waeup.viewStudent')
175    icon = 'actionicon_pdf.png'
176    text = _('Download JHL Id Card')
177    target = 'jhl_idcard.pdf'
178
179    @property
180    def target_url(self):
[15371]181        if self.context.library:
182            return self.view.url(self.view.context, self.target)
183        return
[15352]184
[14834]185class JUPEBResultSlipActionButton(ManageActionButton):
186    grok.order(11)
187    grok.context(ICustomStudent)
188    grok.view(StudentBaseDisplayFormPage)
189    grok.require('waeup.viewStudent')
190    icon = 'actionicon_pdf.png'
191    text = _('Download JUPEB result slip')
192    target = 'jupeb_result_slip.pdf'
193
194    @property
195    def target_url(self):
[14902]196        if self.context.flash_notice and self.context.is_jupeb \
[14835]197            and 'results' in self.context.flash_notice.lower():
[14834]198            return self.view.url(self.view.context, self.target)
199        return False
200
[16383]201class MedicalHistoryEditActionButton(ManageActionButton):
[16382]202    grok.order(12)
203    grok.context(ICustomStudent)
204    grok.view(StudentBaseDisplayFormPage)
205    grok.require('waeup.handleStudent')
[16385]206    text = _('Medical Questionnaire')
[16382]207    target = 'edit_medical'
208    icon = 'actionicon_medical.png'
209
[16383]210class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
211    grok.require('waeup.manageStudent')
212    text = _('Manage medical history')
213    target = 'manage_medical'
214
[16382]215class MedicalHistorySlipActionButton(ManageActionButton):
216    grok.order(1)
217    grok.context(ICustomStudent)
218    grok.view(StudentMedicalHistoryEditFormPage)
219    grok.require('waeup.viewStudent')
220    icon = 'actionicon_pdf.png'
[16385]221    text = _('Download medical questionnaire slip')
222    target = 'medical_questionnaire_slip.pdf'
[16382]223
[17255]224class TishipSlipActionButton(ManageActionButton):
225    grok.order(2)
226    grok.context(ICustomStudent)
[17395]227    grok.view(StudentBaseDisplayFormPage)
[17255]228    grok.require('waeup.viewStudent')
229    icon = 'actionicon_pdf.png'
230    text = _('Download TISHIP registration slip')
231    target = 'tiship_slip.pdf'
232
[16808]233class PlagTestLinkActionButton(ManageActionButton):
234    grok.order(10) 
235    grok.context(ICustomStudentOnlinePayment)
236    grok.view(OnlinePaymentDisplayFormPage)
237    grok.require('waeup.viewStudent')
238    icon = 'actionicon_up.png'
239    text = _('Upload project/thesis file')
240    target = 'plagtestinfo'
241
242    @property
243    def target_url(self):
244        if self.context.p_state != 'paid' \
245            or self.context.p_category != 'plag_test':
246            return ''
247        return self.view.url(self.view.context, self.target)
248
[9382]249# JAMB Letter
250
[12452]251class JAMBLetterDisplay(StudentFileDisplay):
[9382]252    """JAMB Letter display viewlet.
253    """
254    grok.order(19)
255    label = _(u'JAMB Letter')
256    title = _(u'JAMB Letter')
[11556]257    download_name = u'jamb_letter'
[9382]258
259class JAMBLetterSlip(JAMBLetterDisplay):
[13063]260    grok.view(ExportPDFClearanceSlip)
[9382]261
[12452]262class JAMBLetterUpload(StudentFileUpload):
[9382]263    """JAMB Letter upload viewlet.
264    """
265    grok.order(19)
266    label = _(u'JAMB Letter')
267    title = _(u'JAMB Letter Scan')
268    mus = 1024 * 150
[11556]269    download_name = u'jamb_letter'
[9382]270
[12452]271class JAMBLetterImage(StudentImage):
[9382]272    """Renders JAMB Letter scan.
273    """
[11556]274    grok.name('jamb_letter')
275    download_name = u'jamb_letter'
[9382]276
277# Affidavit of Non-Membership of Secret Cults
278
[12452]279class SecrCultsStatementDisplay(StudentFileDisplay):
[9382]280    """Affidavit of Non-Membership of Secret Cults display viewlet.
281    """
282    grok.order(20)
283    label = _(u'Affidavit of Non-Membership of Secret Cults')
284    title = _(u'Affidavit of Non-Membership of Secret Cults')
285    download_name = u'secr_cults'
286
287class SecrCultsStatementSlip(SecrCultsStatementDisplay):
[13063]288    grok.view(ExportPDFClearanceSlip)
[9382]289
[12452]290class SecrCultsStatementUpload(StudentFileUpload):
[9382]291    """Affidavit of Non-Membership of Secret Cults upload viewlet.
292    """
293    grok.order(20)
294    label = _(u'Affidavit of Non-Membership of Secret Cults')
295    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
296    mus = 1024 * 150
297    download_name = u'secr_cults'
298
[12452]299class SecrCultsStatementImage(StudentImage):
[9382]300    """Renders Affidavit of Non-Membership of Secret Cults scan.
301    """
302    grok.name('secr_cults')
[11611]303    download_name = u'secr_cults'
304
[16364]305# O Level Results Scratch Card
[16359]306
[16364]307class OLevelResultsScratchCardDisplay(StudentFileDisplay):
308    """O'Level Results Scratch Card display viewlet.
[16359]309    """
310    grok.order(20)
[16364]311    label = _(u'O Level Results Scratch Card')
312    title = _(u'O Level Results Scratch Card')
313    download_name = u'olevel_sc'
[16359]314
[16364]315class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
[16359]316    grok.view(ExportPDFClearanceSlip)
317
[16364]318class OLevelResultsScratchCardUpload(StudentFileUpload):
319    """O Level Results Scratch Card upload viewlet.
[16359]320    """
321    grok.order(20)
[16364]322    label = _(u'O Level Results Scratch Card')
323    title = _(u'O Level Results Scratch Card Scan')
[16359]324    mus = 1024 * 150
[16364]325    download_name = u'olevel_sc'
[16359]326
[16364]327class OLevelResultsScratchCardImage(StudentImage):
328    """Renders O Level Results Scratch Card scan.
[16359]329    """
[16364]330    grok.name('olevel_sc')
331    download_name = u'olevel_sc'
[16359]332
[11611]333# Fingerprints
334
[12452]335class LeftThumbPrintDisplay(StudentFileDisplay):
[11611]336    """Left thumb fingerprint display viewlet.
337    """
338    grok.order(21)
339    label = _(u'Left Thumb Fingerprint')
340    title = _(u'Left Thumb Fingerprint Minutiae')
341    download_name = u'finger1.fpm'
342
343class LeftThumbPrintSlip(LeftThumbPrintDisplay):
344    """Mentions scanned fingerprint on slip.
[16443]345    Fingerprint minutiae is not printed.
[11611]346    """
[13063]347    grok.view(ExportPDFClearanceSlip)
[11611]348
[12452]349class LeftThumbPrintUpload(StudentFileUpload):
[11611]350    """Left thumb fingerprint upload viewlet.
351    """
352    grok.order(21)
[11613]353    grok.require('waeup.manageStudent')
[11611]354    label = _(u'Left Thumb Fingerprint')
355    title = _(u'Left Thumb Fingerprint Minutiae')
[16363]356    mus = 1024 * 150
[11611]357    download_name = u'finger1.fpm'
358
[12452]359class LeftThumbPrintImage(StudentImage):
[11611]360    """Renders left thumb fingerprint minutiae for download.
361    """
362    grok.name('finger1.fpm')
[16423]363    download_name = u'finger1.fpm'
364
[16473]365# Original JAMB picture
[16423]366
[16441]367class JAMBPictureDisplay(PassportDisplay):
[16423]368    """Original JAMB picture display viewlet.
369    """
[16473]370    grok.order(22)
[16423]371    label = _(u'Original JAMB Picture')
372    title = _(u'Original JAMB Picture')
[16443]373    download_name = u'passport2'
[16423]374
375class JAMBPictureSlip(JAMBPictureDisplay):
376    grok.view(ExportPDFClearanceSlip)
377
[16473]378class JAMBPictureUpload(StudentFileUpload):
379    """Original JAMB picture upload viewlet.
380    """
381    grok.order(22)
382    grok.require('waeup.manageStudent')
383    label = _(u'Original JAMB Picture')
384    title = _(u'Original JAMB Picture')
385    mus = 1024 * 150
386    download_name = u'passport2'
387
[16423]388class JAMBPictureImage(StudentImage):
389    """Renders Original JAMB picture.
390    """
[16443]391    grok.name('passport2')
392    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.