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

Last change on this file since 16457 was 16457, checked in by Henrik Bettermann, 4 years ago

Show upload button.

  • Property svn:keywords set to Id
File size: 10.8 KB
RevLine 
[9382]1## $Id: viewlets.py 16457 2021-04-13 11:51: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
[16361]20from zope.component import getUtility
21from waeup.kofa.interfaces import REQUESTED, REGISTERED, IExtFileStore
[9439]22from waeup.kofa.browser.viewlets import ManageActionButton
[16361]23from waeup.kofa.students.interfaces import IStudentsUtils
[12423]24from waeup.kofa.students.fileviewlets import (
[16441]25    StudentFileDisplay, StudentFileUpload, StudentImage, PassportDisplay)
[9439]26from waeup.kofa.students.browser import (
[13063]27    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
[13723]28    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
29    StudentBaseDisplayFormPage)
[16361]30from waeup.kofa.students.viewlets import (
31    RequestTranscriptActionButton, StudentPassportActionButton)
[9382]32
[16361]33from waeup.uniben.students.interfaces import (
34    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
[16362]35    ICustomStudent,)
[16361]36
[16382]37from waeup.uniben.students.browser import StudentMedicalHistoryEditFormPage
38
[9382]39from kofacustom.nigeria.interfaces import MessageFactory as _
40
[16449]41class RequestTranscriptActionButton(RequestTranscriptActionButton):
[16130]42
43    @property
44    def target_url(self):
45        return ''
46
[16449]47class StudentPassportActionButton(StudentPassportActionButton):
[16361]48
49    @property
50    def target_url(self):
[16362]51        # Uniben: Only 2020 session students are allowed to edit the picture.
52        if self.context.entry_session != 2020:
53            return ''
[16361]54        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
[16457]55        if self.context.state not in PORTRAIT_CHANGE_STATES:
[16361]56            return ''
57        return self.view.url(self.view.context, self.target)
58
[15371]59class SwitchLibraryAccessActionButton(ManageActionButton):
60    grok.order(7)
61    grok.context(ICustomStudent)
62    grok.view(StudentBaseDisplayFormPage)
63    grok.require('waeup.switchLibraryAccess')
64    text = _('Switch library access')
65    target = 'switch_library_access'
66    icon = 'actionicon_book.png'
67
[9439]68class StudyCourseEditActionButton(ManageActionButton):
69    grok.order(1)
70    grok.context(ICustomStudentStudyCourse)
71    grok.view(StudyCourseDisplayFormPage)
72    grok.require('waeup.clearStudent')
73    text = _('Edit level')
74    target = 'edit_level'
[9382]75
[9439]76    @property
77    def target_url(self):
78        if self.context.is_current and self.context.student.state == REQUESTED:
79            return self.view.url(self.view.context, self.target)
80        return False
81
[12855]82class CourseRegistrationSlipActionButton(ManageActionButton):
83    grok.order(5)
84    grok.context(ICustomStudentStudyLevel)
85    grok.view(StudyLevelDisplayFormPage)
86    grok.require('waeup.viewStudent')
87    icon = 'actionicon_pdf.png'
88    text = _('Download course registration slip')
89    target = 'course_registration_slip.pdf'
90
91    @property
92    def target_url(self):
93        is_current = self.context.__parent__.is_current
94        if not is_current:
95            return ''
96        if self.context.student.state != REGISTERED \
97            or self.context.student.current_level != self.context.level:
98            return ''
99        return self.view.url(self.view.context, self.target)
100
[9848]101class CourseResultSlipActionButton(ManageActionButton):
102    grok.order(6)
103    grok.context(ICustomStudentStudyLevel)
104    grok.view(StudyLevelDisplayFormPage)
105    grok.require('waeup.viewStudent')
106    icon = 'actionicon_pdf.png'
107    text = _('Download course result slip')
108    target = 'course_result_slip.pdf'
109
110    @property
111    def target_url(self):
112        return self.view.url(self.view.context, self.target)
113
[12121]114
115class ClearanceInvitationSlipActionButton(ManageActionButton):
116    grok.order(5)
117    grok.context(ICustomStudent)
118    grok.view(StudentClearanceDisplayFormPage)
119    grok.require('waeup.viewStudent')
120    icon = 'actionicon_pdf.png'
121    text = _('Download clearance invitation slip')
122    target = 'clearance_invitation_slip.pdf'
123
[12122]124    @property
125    def target_url(self):
126        if self.context.student.state == REQUESTED \
127            and self.context.student.physical_clearance_date:
128            return self.view.url(self.view.context, self.target)
129        return False
[12121]130
[13723]131class ExaminationScheduleSlipActionButton(ManageActionButton):
132    grok.order(10)
133    grok.context(ICustomStudent)
134    grok.view(StudentBaseDisplayFormPage)
135    grok.require('waeup.viewStudent')
136    icon = 'actionicon_pdf.png'
137    text = _('Download examination schedule slip')
138    target = 'examination_schedule_slip.pdf'
[12122]139
[13723]140    @property
141    def target_url(self):
142        if self.context.flash_notice \
143            and 'exam' in self.context.flash_notice.lower():
144            return self.view.url(self.view.context, self.target)
145        return False
146
[15352]147class JHLIdCardActionButton(ManageActionButton):
148    grok.order(10)
149    grok.context(ICustomStudent)
150    grok.view(StudentBaseDisplayFormPage)
151    grok.require('waeup.viewStudent')
152    icon = 'actionicon_pdf.png'
153    text = _('Download JHL Id Card')
154    target = 'jhl_idcard.pdf'
155
156    @property
157    def target_url(self):
[15371]158        if self.context.library:
159            return self.view.url(self.view.context, self.target)
160        return
[15352]161
[14834]162class JUPEBResultSlipActionButton(ManageActionButton):
163    grok.order(11)
164    grok.context(ICustomStudent)
165    grok.view(StudentBaseDisplayFormPage)
166    grok.require('waeup.viewStudent')
167    icon = 'actionicon_pdf.png'
168    text = _('Download JUPEB result slip')
169    target = 'jupeb_result_slip.pdf'
170
171    @property
172    def target_url(self):
[14902]173        if self.context.flash_notice and self.context.is_jupeb \
[14835]174            and 'results' in self.context.flash_notice.lower():
[14834]175            return self.view.url(self.view.context, self.target)
176        return False
177
[16383]178class MedicalHistoryEditActionButton(ManageActionButton):
[16382]179    grok.order(12)
180    grok.context(ICustomStudent)
181    grok.view(StudentBaseDisplayFormPage)
182    grok.require('waeup.handleStudent')
[16385]183    text = _('Medical Questionnaire')
[16382]184    target = 'edit_medical'
185    icon = 'actionicon_medical.png'
186
[16383]187class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton):
188    grok.require('waeup.manageStudent')
189    text = _('Manage medical history')
190    target = 'manage_medical'
191
[16382]192class MedicalHistorySlipActionButton(ManageActionButton):
193    grok.order(1)
194    grok.context(ICustomStudent)
195    grok.view(StudentMedicalHistoryEditFormPage)
196    grok.require('waeup.viewStudent')
197    icon = 'actionicon_pdf.png'
[16385]198    text = _('Download medical questionnaire slip')
199    target = 'medical_questionnaire_slip.pdf'
[16382]200
[9382]201# JAMB Letter
202
[12452]203class JAMBLetterDisplay(StudentFileDisplay):
[9382]204    """JAMB Letter display viewlet.
205    """
206    grok.order(19)
207    label = _(u'JAMB Letter')
208    title = _(u'JAMB Letter')
[11556]209    download_name = u'jamb_letter'
[9382]210
211class JAMBLetterSlip(JAMBLetterDisplay):
[13063]212    grok.view(ExportPDFClearanceSlip)
[9382]213
[12452]214class JAMBLetterUpload(StudentFileUpload):
[9382]215    """JAMB Letter upload viewlet.
216    """
217    grok.order(19)
218    label = _(u'JAMB Letter')
219    title = _(u'JAMB Letter Scan')
220    mus = 1024 * 150
[11556]221    download_name = u'jamb_letter'
[9382]222
[12452]223class JAMBLetterImage(StudentImage):
[9382]224    """Renders JAMB Letter scan.
225    """
[11556]226    grok.name('jamb_letter')
227    download_name = u'jamb_letter'
[9382]228
229# Affidavit of Non-Membership of Secret Cults
230
[12452]231class SecrCultsStatementDisplay(StudentFileDisplay):
[9382]232    """Affidavit of Non-Membership of Secret Cults display viewlet.
233    """
234    grok.order(20)
235    label = _(u'Affidavit of Non-Membership of Secret Cults')
236    title = _(u'Affidavit of Non-Membership of Secret Cults')
237    download_name = u'secr_cults'
238
239class SecrCultsStatementSlip(SecrCultsStatementDisplay):
[13063]240    grok.view(ExportPDFClearanceSlip)
[9382]241
[12452]242class SecrCultsStatementUpload(StudentFileUpload):
[9382]243    """Affidavit of Non-Membership of Secret Cults upload viewlet.
244    """
245    grok.order(20)
246    label = _(u'Affidavit of Non-Membership of Secret Cults')
247    title = _(u'Affidavit of Non-Membership of Secret Cults Scan')
248    mus = 1024 * 150
249    download_name = u'secr_cults'
250
[12452]251class SecrCultsStatementImage(StudentImage):
[9382]252    """Renders Affidavit of Non-Membership of Secret Cults scan.
253    """
254    grok.name('secr_cults')
[11611]255    download_name = u'secr_cults'
256
[16364]257# O Level Results Scratch Card
[16359]258
[16364]259class OLevelResultsScratchCardDisplay(StudentFileDisplay):
260    """O'Level Results Scratch Card display viewlet.
[16359]261    """
262    grok.order(20)
[16364]263    label = _(u'O Level Results Scratch Card')
264    title = _(u'O Level Results Scratch Card')
265    download_name = u'olevel_sc'
[16359]266
[16364]267class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay):
[16359]268    grok.view(ExportPDFClearanceSlip)
269
[16364]270class OLevelResultsScratchCardUpload(StudentFileUpload):
271    """O Level Results Scratch Card upload viewlet.
[16359]272    """
273    grok.order(20)
[16364]274    label = _(u'O Level Results Scratch Card')
275    title = _(u'O Level Results Scratch Card Scan')
[16359]276    mus = 1024 * 150
[16364]277    download_name = u'olevel_sc'
[16359]278
[16364]279class OLevelResultsScratchCardImage(StudentImage):
280    """Renders O Level Results Scratch Card scan.
[16359]281    """
[16364]282    grok.name('olevel_sc')
283    download_name = u'olevel_sc'
[16359]284
[11611]285# Fingerprints
286
[12452]287class LeftThumbPrintDisplay(StudentFileDisplay):
[11611]288    """Left thumb fingerprint display viewlet.
289    """
290    grok.order(21)
291    label = _(u'Left Thumb Fingerprint')
292    title = _(u'Left Thumb Fingerprint Minutiae')
293    download_name = u'finger1.fpm'
294
295class LeftThumbPrintSlip(LeftThumbPrintDisplay):
296    """Mentions scanned fingerprint on slip.
[16443]297    Fingerprint minutiae is not printed.
[11611]298    """
[13063]299    grok.view(ExportPDFClearanceSlip)
[11611]300
[12452]301class LeftThumbPrintUpload(StudentFileUpload):
[11611]302    """Left thumb fingerprint upload viewlet.
303    """
304    grok.order(21)
[11613]305    grok.require('waeup.manageStudent')
[11611]306    label = _(u'Left Thumb Fingerprint')
307    title = _(u'Left Thumb Fingerprint Minutiae')
[16363]308    mus = 1024 * 150
[11611]309    download_name = u'finger1.fpm'
310
[12452]311class LeftThumbPrintImage(StudentImage):
[11611]312    """Renders left thumb fingerprint minutiae for download.
313    """
314    grok.name('finger1.fpm')
[16423]315    download_name = u'finger1.fpm'
316
317# O Original JAMB picture (view only))
318
[16441]319class JAMBPictureDisplay(PassportDisplay):
[16423]320    """Original JAMB picture display viewlet.
321    """
322    grok.order(20)
323    label = _(u'Original JAMB Picture')
324    title = _(u'Original JAMB Picture')
[16443]325    download_name = u'passport2'
[16423]326
327class JAMBPictureSlip(JAMBPictureDisplay):
328    grok.view(ExportPDFClearanceSlip)
329
330class JAMBPictureImage(StudentImage):
331    """Renders Original JAMB picture.
332    """
[16443]333    grok.name('passport2')
334    download_name = u'passport2'
Note: See TracBrowser for help on using the repository browser.