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

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

Allow also part time students to edit their picture.

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