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

Last change on this file since 17808 was 17807, checked in by Henrik Bettermann, 6 months ago

tighten up some of those allowances

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