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
Line 
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
20from zope.component import getUtility
21from waeup.kofa.interfaces import REQUESTED, REGISTERED, IExtFileStore
22from waeup.kofa.browser.viewlets import ManageActionButton
23from waeup.kofa.students.interfaces import IStudentsUtils
24from waeup.kofa.students.fileviewlets import (
25    StudentFileDisplay, StudentFileUpload, StudentImage, PassportDisplay)
26from waeup.kofa.students.browser import (
27    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
28    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
29    StudentBaseDisplayFormPage, OnlinePaymentDisplayFormPage)
30from waeup.kofa.students.viewlets import (
31    RequestTranscriptActionButton, StudentPassportActionButton,
32    TranscriptSlipActionButton,
33    StudyCourseTranscriptActionButton)
34
35from waeup.uniben.students.interfaces import (
36    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
37    ICustomStudent, ICustomStudentOnlinePayment)
38
39from waeup.uniben.students.browser import StudentMedicalHistoryEditFormPage
40
41from kofacustom.nigeria.interfaces import MessageFactory as _
42
43class RequestTranscriptActionButton(RequestTranscriptActionButton):
44
45    @property
46    def target_url(self):
47        return ''
48
49class TranscriptSlipActionButton(TranscriptSlipActionButton):
50    grok.require('waeup.viewStudent')
51
52class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton):
53    grok.require('waeup.viewStudent')
54
55class StudentPassportActionButton(StudentPassportActionButton):
56
57    @property
58    def target_url(self):
59        # Uniben: Only 2020 session students are allowed to edit the picture.
60        if self.context.entry_session != 2020:
61            return ''
62        if self.context.entry_mode not in ('ug_ft', 'de_ft'):
63            return ''
64        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
65        if self.context.state not in PORTRAIT_CHANGE_STATES:
66            return ''
67        return self.view.url(self.view.context, self.target)
68
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
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'
85
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
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
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
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
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
140
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'
149
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
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):
168        if self.context.library:
169            return self.view.url(self.view.context, self.target)
170        return
171
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):
183        if self.context.flash_notice and self.context.is_jupeb \
184            and 'results' in self.context.flash_notice.lower():
185            return self.view.url(self.view.context, self.target)
186        return False
187
188class MedicalHistoryEditActionButton(ManageActionButton):
189    grok.order(12)
190    grok.context(ICustomStudent)
191    grok.view(StudentBaseDisplayFormPage)
192    grok.require('waeup.handleStudent')
193    text = _('Medical Questionnaire')
194    target = 'edit_medical'
195    icon = 'actionicon_medical.png'
196
197class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
198    grok.require('waeup.manageStudent')
199    text = _('Manage medical history')
200    target = 'manage_medical'
201
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'
208    text = _('Download medical questionnaire slip')
209    target = 'medical_questionnaire_slip.pdf'
210
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
227# JAMB Letter
228
229class JAMBLetterDisplay(StudentFileDisplay):
230    """JAMB Letter display viewlet.
231    """
232    grok.order(19)
233    label = _(u'JAMB Letter')
234    title = _(u'JAMB Letter')
235    download_name = u'jamb_letter'
236
237class JAMBLetterSlip(JAMBLetterDisplay):
238    grok.view(ExportPDFClearanceSlip)
239
240class JAMBLetterUpload(StudentFileUpload):
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
247    download_name = u'jamb_letter'
248
249class JAMBLetterImage(StudentImage):
250    """Renders JAMB Letter scan.
251    """
252    grok.name('jamb_letter')
253    download_name = u'jamb_letter'
254
255# Affidavit of Non-Membership of Secret Cults
256
257class SecrCultsStatementDisplay(StudentFileDisplay):
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):
266    grok.view(ExportPDFClearanceSlip)
267
268class SecrCultsStatementUpload(StudentFileUpload):
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
277class SecrCultsStatementImage(StudentImage):
278    """Renders Affidavit of Non-Membership of Secret Cults scan.
279    """
280    grok.name('secr_cults')
281    download_name = u'secr_cults'
282
283# O Level Results Scratch Card
284
285class OLevelResultsScratchCardDisplay(StudentFileDisplay):
286    """O'Level Results Scratch Card display viewlet.
287    """
288    grok.order(20)
289    label = _(u'O Level Results Scratch Card')
290    title = _(u'O Level Results Scratch Card')
291    download_name = u'olevel_sc'
292
293class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
294    grok.view(ExportPDFClearanceSlip)
295
296class OLevelResultsScratchCardUpload(StudentFileUpload):
297    """O Level Results Scratch Card upload viewlet.
298    """
299    grok.order(20)
300    label = _(u'O Level Results Scratch Card')
301    title = _(u'O Level Results Scratch Card Scan')
302    mus = 1024 * 150
303    download_name = u'olevel_sc'
304
305class OLevelResultsScratchCardImage(StudentImage):
306    """Renders O Level Results Scratch Card scan.
307    """
308    grok.name('olevel_sc')
309    download_name = u'olevel_sc'
310
311# Fingerprints
312
313class LeftThumbPrintDisplay(StudentFileDisplay):
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.
323    Fingerprint minutiae is not printed.
324    """
325    grok.view(ExportPDFClearanceSlip)
326
327class LeftThumbPrintUpload(StudentFileUpload):
328    """Left thumb fingerprint upload viewlet.
329    """
330    grok.order(21)
331    grok.require('waeup.manageStudent')
332    label = _(u'Left Thumb Fingerprint')
333    title = _(u'Left Thumb Fingerprint Minutiae')
334    mus = 1024 * 150
335    download_name = u'finger1.fpm'
336
337class LeftThumbPrintImage(StudentImage):
338    """Renders left thumb fingerprint minutiae for download.
339    """
340    grok.name('finger1.fpm')
341    download_name = u'finger1.fpm'
342
343# Original JAMB picture
344
345class JAMBPictureDisplay(PassportDisplay):
346    """Original JAMB picture display viewlet.
347    """
348    grok.order(22)
349    label = _(u'Original JAMB Picture')
350    title = _(u'Original JAMB Picture')
351    download_name = u'passport2'
352
353class JAMBPictureSlip(JAMBPictureDisplay):
354    grok.view(ExportPDFClearanceSlip)
355
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
366class JAMBPictureImage(StudentImage):
367    """Renders Original JAMB picture.
368    """
369    grok.name('passport2')
370    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.