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

Last change on this file since 17822 was 17822, checked in by Henrik Bettermann, 5 months ago

Implement NYSC request pages.

  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1## $Id: viewlets.py 17822 2024-06-27 07:47:23Z 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,
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
239class NYSCEditActionButton(ManageActionButton):
240    grok.order(13)
241    grok.context(ICustomStudent)
242    grok.view(StudentBaseDisplayFormPage)
243    grok.require('waeup.handleStudent')
244    text = _('NYSC Request')
245    target = 'edit_nysc'
246    icon = 'actionicon_nigeria.png'
247
248    @property
249    def target_url(self):
250        if not self.context.eligible_for_nysc:
251            return ''
252        return self.view.url(self.view.context, self.target)
253
254class NYSCManageActionButton(ManageActionButton):
255    grok.require('waeup.manageStudent')
256    text = _('Manage NYSC request data')
257    target = 'manage_nysc'
258    grok.order(13)
259    grok.context(ICustomStudent)
260    grok.view(StudentBaseDisplayFormPage)
261    icon = 'actionicon_nigeria.png'
262
263# JAMB Letter
264
265class JAMBLetterDisplay(StudentFileDisplay):
266    """JAMB Letter display viewlet.
267    """
268    grok.order(19)
269    label = _(u'JAMB Letter')
270    title = _(u'JAMB Letter')
271    download_name = u'jamb_letter'
272
273class JAMBLetterSlip(JAMBLetterDisplay):
274    grok.view(ExportPDFClearanceSlip)
275
276class JAMBLetterUpload(StudentFileUpload):
277    """JAMB Letter upload viewlet.
278    """
279    grok.order(19)
280    label = _(u'JAMB Letter')
281    title = _(u'JAMB Letter Scan')
282    mus = 1024 * 150
283    download_name = u'jamb_letter'
284
285class JAMBLetterImage(StudentImage):
286    """Renders JAMB Letter scan.
287    """
288    grok.name('jamb_letter')
289    download_name = u'jamb_letter'
290
291# Affidavit of Non-Membership of Secret Cults
292
293class SecrCultsStatementDisplay(StudentFileDisplay):
294    """Affidavit of Non-Membership of Secret Cults display viewlet.
295    """
296    grok.order(20)
297    label = _(u'Affidavit of Non-Membership of Secret Cults')
298    title = _(u'Affidavit of Non-Membership of Secret Cults')
299    download_name = u'secr_cults'
300
301class SecrCultsStatementSlip(SecrCultsStatementDisplay):
302    grok.view(ExportPDFClearanceSlip)
303
304class SecrCultsStatementUpload(StudentFileUpload):
305    """Affidavit of Non-Membership of Secret Cults upload viewlet.
306    """
307    grok.order(20)
308    label = _(u'Affidavit of Non-Membership of Secret Cults')
309    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
310    mus = 1024 * 150
311    download_name = u'secr_cults'
312
313class SecrCultsStatementImage(StudentImage):
314    """Renders Affidavit of Non-Membership of Secret Cults scan.
315    """
316    grok.name('secr_cults')
317    download_name = u'secr_cults'
318
319# O Level Results Scratch Card
320
321class OLevelResultsScratchCardDisplay(StudentFileDisplay):
322    """O'Level Results Scratch Card display viewlet.
323    """
324    grok.order(20)
325    label = _(u'O Level Results Scratch Card')
326    title = _(u'O Level Results Scratch Card')
327    download_name = u'olevel_sc'
328
329class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
330    grok.view(ExportPDFClearanceSlip)
331
332class OLevelResultsScratchCardUpload(StudentFileUpload):
333    """O Level Results Scratch Card upload viewlet.
334    """
335    grok.order(20)
336    label = _(u'O Level Results Scratch Card')
337    title = _(u'O Level Results Scratch Card Scan')
338    mus = 1024 * 150
339    download_name = u'olevel_sc'
340
341class OLevelResultsScratchCardImage(StudentImage):
342    """Renders O Level Results Scratch Card scan.
343    """
344    grok.name('olevel_sc')
345    download_name = u'olevel_sc'
346
347# Fingerprints
348
349class LeftThumbPrintDisplay(StudentFileDisplay):
350    """Left thumb fingerprint display viewlet.
351    """
352    grok.order(21)
353    label = _(u'Left Thumb Fingerprint')
354    title = _(u'Left Thumb Fingerprint Minutiae')
355    download_name = u'finger1.fpm'
356
357class LeftThumbPrintSlip(LeftThumbPrintDisplay):
358    """Mentions scanned fingerprint on slip.
359    Fingerprint minutiae is not printed.
360    """
361    grok.view(ExportPDFClearanceSlip)
362
363class LeftThumbPrintUpload(StudentFileUpload):
364    """Left thumb fingerprint upload viewlet.
365    """
366    grok.order(21)
367    grok.require('waeup.manageStudent')
368    label = _(u'Left Thumb Fingerprint')
369    title = _(u'Left Thumb Fingerprint Minutiae')
370    mus = 1024 * 150
371    download_name = u'finger1.fpm'
372
373class LeftThumbPrintImage(StudentImage):
374    """Renders left thumb fingerprint minutiae for download.
375    """
376    grok.name('finger1.fpm')
377    download_name = u'finger1.fpm'
378
379# Original JAMB picture
380
381class JAMBPictureDisplay(PassportDisplay):
382    """Original JAMB picture display viewlet.
383    """
384    grok.order(22)
385    label = _(u'Original JAMB Picture')
386    title = _(u'Original JAMB Picture')
387    download_name = u'passport2'
388
389class JAMBPictureSlip(JAMBPictureDisplay):
390    grok.view(ExportPDFClearanceSlip)
391
392class JAMBPictureUpload(StudentFileUpload):
393    """Original JAMB picture upload viewlet.
394    """
395    grok.order(22)
396    grok.require('waeup.manageStudent')
397    label = _(u'Original JAMB Picture')
398    title = _(u'Original JAMB Picture')
399    mus = 1024 * 150
400    download_name = u'passport2'
401
402class JAMBPictureImage(StudentImage):
403    """Renders Original JAMB picture.
404    """
405    grok.name('passport2')
406    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.