## $Id: viewlets.py 17885 2024-08-11 19:29:13Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import grok from zope.component import getUtility from waeup.kofa.interfaces import REQUESTED, REGISTERED, CLEARED, IExtFileStore from waeup.kofa.browser.viewlets import ManageActionButton from waeup.kofa.students.interfaces import IStudentsUtils from waeup.kofa.students.fileviewlets import ( StudentFileDisplay, StudentFileUpload, StudentImage, PassportDisplay) from waeup.kofa.students.browser import ( ExportPDFClearanceSlip, StudyCourseDisplayFormPage, StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage, StudentBaseDisplayFormPage, StudentBaseManageFormPage, OnlinePaymentDisplayFormPage) from waeup.kofa.students.viewlets import ( RequestTranscriptActionButton, TranscriptSlipActionButton, StudyCourseTranscriptActionButton) from waeup.uniben.students.interfaces import ( ICustomStudentStudyCourse, ICustomStudentStudyLevel, ICustomStudent, ICustomStudentOnlinePayment) from waeup.uniben.students.browser import ( StudentMedicalHistoryEditFormPage, StudentAffidavitUploadPage, StudentAffidavitUploadPage) from kofacustom.nigeria.interfaces import MessageFactory as _ class RequestTranscriptActionButton(RequestTranscriptActionButton): @property def target_url(self): return '' class TranscriptSlipActionButton(TranscriptSlipActionButton): grok.require('waeup.viewStudent') class StudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton): grok.require('waeup.viewStudent') class SwitchLibraryAccessActionButton(ManageActionButton): grok.order(7) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.switchLibraryAccess') text = _('Switch library access') target = 'switch_library_access' icon = 'actionicon_book.png' class StudyCourseEditActionButton(ManageActionButton): grok.order(1) grok.context(ICustomStudentStudyCourse) grok.view(StudyCourseDisplayFormPage) grok.require('waeup.clearStudent') text = _('Edit level') target = 'edit_level' @property def target_url(self): if self.context.is_current and self.context.student.state == REQUESTED: return self.view.url(self.view.context, self.target) return False class CourseRegistrationSlipActionButton(ManageActionButton): grok.order(5) grok.context(ICustomStudentStudyLevel) grok.view(StudyLevelDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download course registration slip') target = 'course_registration_slip.pdf' @property def target_url(self): is_current = self.context.__parent__.is_current if not is_current: return '' if self.context.student.state != REGISTERED \ or self.context.student.current_level != self.context.level: return '' return self.view.url(self.view.context, self.target) class CourseResultSlipActionButton(ManageActionButton): grok.order(6) grok.context(ICustomStudentStudyLevel) grok.view(StudyLevelDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download course result slip') target = 'course_result_slip.pdf' @property def target_url(self): return self.view.url(self.view.context, self.target) class ClearanceInvitationSlipActionButton(ManageActionButton): grok.order(5) grok.context(ICustomStudent) grok.view(StudentClearanceDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download clearance invitation slip') target = 'clearance_invitation_slip.pdf' @property def target_url(self): if self.context.student.state == REQUESTED \ and self.context.student.physical_clearance_date: return self.view.url(self.view.context, self.target) return False class MadicalExaminationSlipActionButton(ManageActionButton): grok.order(6) grok.context(ICustomStudent) grok.view(StudentClearanceDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download medical examination slip') target = 'medical_examination_slip.pdf' @property def target_url(self): if self.context.student.state == CLEARED \ and self.context.student.physical_clearance_date: return self.view.url(self.view.context, self.target) return False class ExaminationScheduleSlipActionButton(ManageActionButton): grok.order(10) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download examination schedule slip') target = 'examination_schedule_slip.pdf' @property def target_url(self): if self.context.flash_notice \ and 'exam' in self.context.flash_notice.lower(): return self.view.url(self.view.context, self.target) return False class JHLIdCardActionButton(ManageActionButton): grok.order(10) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download JHL Id Card') target = 'jhl_idcard.pdf' @property def target_url(self): if self.context.library: return self.view.url(self.view.context, self.target) return class JUPEBResultSlipActionButton(ManageActionButton): grok.order(11) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download JUPEB result slip') target = 'jupeb_result_slip.pdf' @property def target_url(self): if self.context.flash_notice and self.context.is_jupeb \ and 'results' in self.context.flash_notice.lower(): return self.view.url(self.view.context, self.target) return False class MedicalHistoryEditActionButton(ManageActionButton): grok.order(12) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.handleStudent') text = _('Medical Questionnaire') target = 'edit_medical' icon = 'actionicon_medical.png' class MedicalHistoryManageActionButton(MedicalHistoryEditActionButton): grok.require('waeup.manageStudent') text = _('Manage medical history') target = 'manage_medical' class MedicalHistorySlipActionButton(ManageActionButton): grok.order(1) grok.context(ICustomStudent) grok.view(StudentMedicalHistoryEditFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download medical questionnaire slip') target = 'medical_questionnaire_slip.pdf' class TishipSlipActionButton(ManageActionButton): grok.order(2) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download TISHIP registration slip') target = 'tiship_slip.pdf' class PlagTestLinkActionButton(ManageActionButton): grok.order(10) grok.context(ICustomStudentOnlinePayment) grok.view(OnlinePaymentDisplayFormPage) grok.require('waeup.viewStudent') icon = 'actionicon_up.png' text = _('Upload project/thesis file') target = 'plagtestinfo' @property def target_url(self): if self.context.p_state != 'paid' \ or self.context.p_category != 'plag_test': return '' return self.view.url(self.view.context, self.target) class NYSCEditActionButton(ManageActionButton): grok.order(13) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.handleStudent') text = _('NYSC Request') target = 'edit_nysc' icon = 'actionicon_nigeria.png' @property def target_url(self): if not self.context.eligible_for_nysc: return '' return self.view.url(self.view.context, self.target) class NYSCManageActionButton(ManageActionButton): grok.require('waeup.manageStudent') text = _('Manage NYSC request data') target = 'manage_nysc' grok.order(13) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) icon = 'actionicon_nigeria.png' # Affidavit of Good Behavior class StudentAffidavitUploadActionButton(ManageActionButton): grok.order(14) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.handleStudent') icon = 'actionicon_signature.png' text = _('Upload affidavit of good conduct') target = 'affidavit_upload' class AffidavitDisplay(StudentFileDisplay): """Affidavit of Good Behavior display viewlet. """ grok.order(10) grok.context(ICustomStudent) grok.view(StudentBaseDisplayFormPage) grok.require('waeup.viewStudent') label = _(u'Scanned Affidavit of Good Conduct') download_name = u'affidavit.pdf' class AffidavitSlipActionButton(ManageActionButton): grok.order(1) grok.context(ICustomStudent) grok.view(StudentAffidavitUploadPage) grok.require('waeup.viewStudent') icon = 'actionicon_pdf.png' text = _('Download affidavit of good conduct form') target = 'affidavit_good_conduct.pdf' class AffidavitUploadManage(StudentFileUpload): """Affidavit of Good Behavior upload viewlet for officers. """ grok.order(10) grok.context(ICustomStudent) grok.view(StudentBaseManageFormPage) grok.require('waeup.manageStudent') label = _(u'Scanned Affidavit of Good Conduct (pdf only)') download_name = u'affidavit.pdf' class AffidavitUploadEdit(AffidavitUploadManage): """Affidavit of Good Conduct upload viewlet for students. """ grok.view(StudentAffidavitUploadPage) grok.require('waeup.uploadStudentFile') class AffidavitGoodConduct(StudentImage): """Renders pdf slip. """ grok.name('affidavit.pdf') download_name = u'affidavit' @property def add_id(self): return self.context.student_id # JAMB Letter class JAMBLetterDisplay(StudentFileDisplay): """JAMB Letter display viewlet. """ grok.order(19) label = _(u'JAMB Letter') title = _(u'JAMB Letter') download_name = u'jamb_letter' class JAMBLetterSlip(JAMBLetterDisplay): grok.view(ExportPDFClearanceSlip) class JAMBLetterUpload(StudentFileUpload): """JAMB Letter upload viewlet. """ grok.order(19) label = _(u'JAMB Letter') title = _(u'JAMB Letter Scan') mus = 1024 * 150 download_name = u'jamb_letter' class JAMBLetterImage(StudentImage): """Renders JAMB Letter scan. """ grok.name('jamb_letter') download_name = u'jamb_letter' # Affidavit of Non-Membership of Secret Cults class SecrCultsStatementDisplay(StudentFileDisplay): """Affidavit of Non-Membership of Secret Cults display viewlet. """ grok.order(20) label = _(u'Affidavit of Non-Membership of Secret Cults') title = _(u'Affidavit of Non-Membership of Secret Cults') download_name = u'secr_cults' class SecrCultsStatementSlip(SecrCultsStatementDisplay): grok.view(ExportPDFClearanceSlip) class SecrCultsStatementUpload(StudentFileUpload): """Affidavit of Non-Membership of Secret Cults upload viewlet. """ grok.order(20) label = _(u'Affidavit of Non-Membership of Secret Cults') title = _(u'Affidavit of Non-Membership of Secret Cults Scan') mus = 1024 * 150 download_name = u'secr_cults' class SecrCultsStatementImage(StudentImage): """Renders Affidavit of Non-Membership of Secret Cults scan. """ grok.name('secr_cults') download_name = u'secr_cults' # O Level Results Scratch Card class OLevelResultsScratchCardDisplay(StudentFileDisplay): """O'Level Results Scratch Card display viewlet. """ grok.order(20) label = _(u'O Level Results Scratch Card') title = _(u'O Level Results Scratch Card') download_name = u'olevel_sc' class OLevelResultsScratchCardSlip(OLevelResultsScratchCardDisplay): grok.view(ExportPDFClearanceSlip) class OLevelResultsScratchCardUpload(StudentFileUpload): """O Level Results Scratch Card upload viewlet. """ grok.order(20) label = _(u'O Level Results Scratch Card') title = _(u'O Level Results Scratch Card Scan') mus = 1024 * 150 download_name = u'olevel_sc' class OLevelResultsScratchCardImage(StudentImage): """Renders O Level Results Scratch Card scan. """ grok.name('olevel_sc') download_name = u'olevel_sc' # Fingerprints class LeftThumbPrintDisplay(StudentFileDisplay): """Left thumb fingerprint display viewlet. """ grok.order(21) label = _(u'Left Thumb Fingerprint') title = _(u'Left Thumb Fingerprint Minutiae') download_name = u'finger1.fpm' class LeftThumbPrintSlip(LeftThumbPrintDisplay): """Mentions scanned fingerprint on slip. Fingerprint minutiae is not printed. """ grok.view(ExportPDFClearanceSlip) class LeftThumbPrintUpload(StudentFileUpload): """Left thumb fingerprint upload viewlet. """ grok.order(21) grok.require('waeup.manageStudent') label = _(u'Left Thumb Fingerprint') title = _(u'Left Thumb Fingerprint Minutiae') mus = 1024 * 150 download_name = u'finger1.fpm' class LeftThumbPrintImage(StudentImage): """Renders left thumb fingerprint minutiae for download. """ grok.name('finger1.fpm') download_name = u'finger1.fpm' # Original JAMB picture class JAMBPictureDisplay(PassportDisplay): """Original JAMB picture display viewlet. """ grok.order(22) label = _(u'Original JAMB Picture') title = _(u'Original JAMB Picture') download_name = u'passport2' class JAMBPictureSlip(JAMBPictureDisplay): grok.view(ExportPDFClearanceSlip) class JAMBPictureUpload(StudentFileUpload): """Original JAMB picture upload viewlet. """ grok.order(22) grok.require('waeup.manageStudent') label = _(u'Original JAMB Picture') title = _(u'Original JAMB Picture') mus = 1024 * 150 download_name = u'passport2' class JAMBPictureImage(StudentImage): """Renders Original JAMB picture. """ grok.name('passport2') download_name = u'passport2'