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

Last change on this file since 17185 was 17145, checked in by Henrik Bettermann, 2 years ago

Student id prefix for Uniben CDL is „C“.

Fix viewlet.

  • Property svn:keywords set to Id
File size: 11.8 KB
Line 
1## $Id: viewlets.py 17145 2022-10-27 20:51:43Z 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        if self.context.is_jupeb:
60            return ''
61        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
62        if self.context.state not in PORTRAIT_CHANGE_STATES and not self.context.is_postgrad:
63            return ''
64        return self.view.url(self.view.context, self.target)
65
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
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'
82
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
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
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
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
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
137
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'
146
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
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):
165        if self.context.library:
166            return self.view.url(self.view.context, self.target)
167        return
168
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):
180        if self.context.flash_notice and self.context.is_jupeb \
181            and 'results' in self.context.flash_notice.lower():
182            return self.view.url(self.view.context, self.target)
183        return False
184
185class MedicalHistoryEditActionButton(ManageActionButton):
186    grok.order(12)
187    grok.context(ICustomStudent)
188    grok.view(StudentBaseDisplayFormPage)
189    grok.require('waeup.handleStudent')
190    text = _('Medical Questionnaire')
191    target = 'edit_medical'
192    icon = 'actionicon_medical.png'
193
194class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
195    grok.require('waeup.manageStudent')
196    text = _('Manage medical history')
197    target = 'manage_medical'
198
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'
205    text = _('Download medical questionnaire slip')
206    target = 'medical_questionnaire_slip.pdf'
207
208class PlagTestLinkActionButton(ManageActionButton):
209    grok.order(10) 
210    grok.context(ICustomStudentOnlinePayment)
211    grok.view(OnlinePaymentDisplayFormPage)
212    grok.require('waeup.viewStudent')
213    icon = 'actionicon_up.png'
214    text = _('Upload project/thesis file')
215    target = 'plagtestinfo'
216
217    @property
218    def target_url(self):
219        if self.context.p_state != 'paid' \
220            or self.context.p_category != 'plag_test':
221            return ''
222        return self.view.url(self.view.context, self.target)
223
224# JAMB Letter
225
226class JAMBLetterDisplay(StudentFileDisplay):
227    """JAMB Letter display viewlet.
228    """
229    grok.order(19)
230    label = _(u'JAMB Letter')
231    title = _(u'JAMB Letter')
232    download_name = u'jamb_letter'
233
234class JAMBLetterSlip(JAMBLetterDisplay):
235    grok.view(ExportPDFClearanceSlip)
236
237class JAMBLetterUpload(StudentFileUpload):
238    """JAMB Letter upload viewlet.
239    """
240    grok.order(19)
241    label = _(u'JAMB Letter')
242    title = _(u'JAMB Letter Scan')
243    mus = 1024 * 150
244    download_name = u'jamb_letter'
245
246class JAMBLetterImage(StudentImage):
247    """Renders JAMB Letter scan.
248    """
249    grok.name('jamb_letter')
250    download_name = u'jamb_letter'
251
252# Affidavit of Non-Membership of Secret Cults
253
254class SecrCultsStatementDisplay(StudentFileDisplay):
255    """Affidavit of Non-Membership of Secret Cults display viewlet.
256    """
257    grok.order(20)
258    label = _(u'Affidavit of Non-Membership of Secret Cults')
259    title = _(u'Affidavit of Non-Membership of Secret Cults')
260    download_name = u'secr_cults'
261
262class SecrCultsStatementSlip(SecrCultsStatementDisplay):
263    grok.view(ExportPDFClearanceSlip)
264
265class SecrCultsStatementUpload(StudentFileUpload):
266    """Affidavit of Non-Membership of Secret Cults upload viewlet.
267    """
268    grok.order(20)
269    label = _(u'Affidavit of Non-Membership of Secret Cults')
270    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
271    mus = 1024 * 150
272    download_name = u'secr_cults'
273
274class SecrCultsStatementImage(StudentImage):
275    """Renders Affidavit of Non-Membership of Secret Cults scan.
276    """
277    grok.name('secr_cults')
278    download_name = u'secr_cults'
279
280# O Level Results Scratch Card
281
282class OLevelResultsScratchCardDisplay(StudentFileDisplay):
283    """O'Level Results Scratch Card display viewlet.
284    """
285    grok.order(20)
286    label = _(u'O Level Results Scratch Card')
287    title = _(u'O Level Results Scratch Card')
288    download_name = u'olevel_sc'
289
290class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
291    grok.view(ExportPDFClearanceSlip)
292
293class OLevelResultsScratchCardUpload(StudentFileUpload):
294    """O Level Results Scratch Card upload viewlet.
295    """
296    grok.order(20)
297    label = _(u'O Level Results Scratch Card')
298    title = _(u'O Level Results Scratch Card Scan')
299    mus = 1024 * 150
300    download_name = u'olevel_sc'
301
302class OLevelResultsScratchCardImage(StudentImage):
303    """Renders O Level Results Scratch Card scan.
304    """
305    grok.name('olevel_sc')
306    download_name = u'olevel_sc'
307
308# Fingerprints
309
310class LeftThumbPrintDisplay(StudentFileDisplay):
311    """Left thumb fingerprint display viewlet.
312    """
313    grok.order(21)
314    label = _(u'Left Thumb Fingerprint')
315    title = _(u'Left Thumb Fingerprint Minutiae')
316    download_name = u'finger1.fpm'
317
318class LeftThumbPrintSlip(LeftThumbPrintDisplay):
319    """Mentions scanned fingerprint on slip.
320    Fingerprint minutiae is not printed.
321    """
322    grok.view(ExportPDFClearanceSlip)
323
324class LeftThumbPrintUpload(StudentFileUpload):
325    """Left thumb fingerprint upload viewlet.
326    """
327    grok.order(21)
328    grok.require('waeup.manageStudent')
329    label = _(u'Left Thumb Fingerprint')
330    title = _(u'Left Thumb Fingerprint Minutiae')
331    mus = 1024 * 150
332    download_name = u'finger1.fpm'
333
334class LeftThumbPrintImage(StudentImage):
335    """Renders left thumb fingerprint minutiae for download.
336    """
337    grok.name('finger1.fpm')
338    download_name = u'finger1.fpm'
339
340# Original JAMB picture
341
342class JAMBPictureDisplay(PassportDisplay):
343    """Original JAMB picture display viewlet.
344    """
345    grok.order(22)
346    label = _(u'Original JAMB Picture')
347    title = _(u'Original JAMB Picture')
348    download_name = u'passport2'
349
350class JAMBPictureSlip(JAMBPictureDisplay):
351    grok.view(ExportPDFClearanceSlip)
352
353class JAMBPictureUpload(StudentFileUpload):
354    """Original JAMB picture upload viewlet.
355    """
356    grok.order(22)
357    grok.require('waeup.manageStudent')
358    label = _(u'Original JAMB Picture')
359    title = _(u'Original JAMB Picture')
360    mus = 1024 * 150
361    download_name = u'passport2'
362
363class JAMBPictureImage(StudentImage):
364    """Renders Original JAMB picture.
365    """
366    grok.name('passport2')
367    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.