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

Last change on this file since 16982 was 16906, checked in by Henrik Bettermann, 3 years ago

Allow students to view transcripts but with different watermark.

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