[9527] | 1 | ## $Id: viewlets.py 16967 2022-06-16 07:19:57Z 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 | |
---|
[11597] | 19 | import grok |
---|
| 20 | from zope.component import getUtility |
---|
[13039] | 21 | from waeup.kofa.interfaces import REGISTERED |
---|
[15330] | 22 | from waeup.kofa.students.interfaces import ( |
---|
| 23 | IStudent, IStudentsUtils, IStudentStudyLevel) |
---|
[11607] | 24 | from waeup.kofa.students.workflow import PAID |
---|
[9870] | 25 | from waeup.kofa.students.viewlets import ( |
---|
[11597] | 26 | AddPreviousPaymentActionButton, AddBalancePaymentActionButton, |
---|
[13380] | 27 | ManageActionButton, StudentBaseDisplayFormPage, |
---|
[14207] | 28 | StudentPassportActionButton, |
---|
| 29 | StudyCourseTranscriptActionButton, |
---|
[14288] | 30 | TranscriptSlipActionButton, |
---|
[15424] | 31 | ) |
---|
[13039] | 32 | from waeup.kofa.students.browser import StudyLevelDisplayFormPage |
---|
[9527] | 33 | |
---|
[13489] | 34 | from waeup.aaue.students.interfaces import ( |
---|
| 35 | ICustomStudent, ICustomStudentStudyLevel) |
---|
| 36 | from waeup.aaue.students.browser import CustomStudentPersonalDisplayFormPage |
---|
[11597] | 37 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 38 | |
---|
[14544] | 39 | #class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): |
---|
[9527] | 40 | |
---|
[14544] | 41 | # @property |
---|
| 42 | # def target_url(self): |
---|
| 43 | # return '' |
---|
[9870] | 44 | |
---|
[13637] | 45 | #class AddBalancePaymentActionButton(AddBalancePaymentActionButton): |
---|
[9870] | 46 | |
---|
[13637] | 47 | # @property |
---|
| 48 | # def target_url(self): |
---|
| 49 | # return '' |
---|
[11597] | 50 | |
---|
| 51 | class GetMatricNumberActionButton(ManageActionButton): |
---|
| 52 | grok.order(10) |
---|
| 53 | grok.context(IStudent) |
---|
| 54 | grok.view(StudentBaseDisplayFormPage) |
---|
[11603] | 55 | grok.require('waeup.viewStudent') |
---|
| 56 | #grok.require('waeup.manageStudent') |
---|
[11597] | 57 | icon = 'actionicon_count.png' |
---|
| 58 | text = _('Get Matriculation Number') |
---|
| 59 | |
---|
| 60 | @property |
---|
| 61 | def target_url(self): |
---|
| 62 | students_utils = getUtility(IStudentsUtils) |
---|
| 63 | if self.context.matric_number: |
---|
| 64 | return '' |
---|
[12975] | 65 | error, matric_number = students_utils.constructMatricNumber( |
---|
| 66 | self.context) |
---|
[11626] | 67 | if error: |
---|
[11597] | 68 | return '' |
---|
| 69 | return self.view.url(self.view.context, 'get_matric_number') |
---|
[11607] | 70 | |
---|
| 71 | class MatricNumberSlipActionButton(ManageActionButton): |
---|
| 72 | grok.order(10) |
---|
| 73 | grok.context(IStudent) |
---|
| 74 | grok.view(StudentBaseDisplayFormPage) |
---|
| 75 | grok.require('waeup.viewStudent') |
---|
| 76 | icon = 'actionicon_pdf.png' |
---|
| 77 | text = _('Download matriculation number slip') |
---|
| 78 | target = 'matric_number_slip.pdf' |
---|
| 79 | |
---|
| 80 | @property |
---|
| 81 | def target_url(self): |
---|
| 82 | if self.context.state not in (PAID,) or not self.context.is_fresh \ |
---|
| 83 | or not self.context.matric_number: |
---|
| 84 | return '' |
---|
[13039] | 85 | return self.view.url(self.view.context, self.target) |
---|
| 86 | |
---|
| 87 | class CourseRegistrationSlipActionButton(ManageActionButton): |
---|
| 88 | grok.order(5) |
---|
| 89 | grok.context(ICustomStudentStudyLevel) |
---|
| 90 | grok.view(StudyLevelDisplayFormPage) |
---|
| 91 | grok.require('waeup.viewStudent') |
---|
| 92 | icon = 'actionicon_pdf.png' |
---|
| 93 | text = _('Download course registration slip') |
---|
| 94 | target = 'course_registration_slip.pdf' |
---|
| 95 | |
---|
| 96 | @property |
---|
| 97 | def target_url(self): |
---|
| 98 | is_current = self.context.__parent__.is_current |
---|
| 99 | if not is_current: |
---|
| 100 | return '' |
---|
| 101 | if self.context.student.state != REGISTERED \ |
---|
[13051] | 102 | and self.context.student.current_level == self.context.level: |
---|
[13039] | 103 | return '' |
---|
[13380] | 104 | return self.view.url(self.view.context, self.target) |
---|
| 105 | |
---|
[14661] | 106 | class ExaminationScheduleSlipActionButton(ManageActionButton): |
---|
| 107 | grok.order(10) |
---|
| 108 | grok.context(ICustomStudent) |
---|
| 109 | grok.view(StudentBaseDisplayFormPage) |
---|
| 110 | grok.require('waeup.viewStudent') |
---|
| 111 | icon = 'actionicon_pdf.png' |
---|
| 112 | text = _('Download examination schedule slip') |
---|
| 113 | target = 'examination_schedule_slip.pdf' |
---|
| 114 | |
---|
| 115 | @property |
---|
| 116 | def target_url(self): |
---|
| 117 | if self.context.flash_notice \ |
---|
| 118 | and 'exam' in self.context.flash_notice.lower(): |
---|
| 119 | return self.view.url(self.view.context, self.target) |
---|
| 120 | return False |
---|
| 121 | |
---|
[13489] | 122 | class PersonalDataSlipActionButton(ManageActionButton): |
---|
| 123 | grok.order(3) |
---|
| 124 | grok.context(ICustomStudent) |
---|
| 125 | grok.view(CustomStudentPersonalDisplayFormPage) |
---|
| 126 | grok.require('waeup.viewStudent') |
---|
| 127 | icon = 'actionicon_pdf.png' |
---|
| 128 | text = _('Download personal data slip') |
---|
| 129 | target = 'personal_data_slip.pdf' |
---|
| 130 | |
---|
| 131 | @property |
---|
| 132 | def target_url(self): |
---|
| 133 | if not self.context.father_name: |
---|
| 134 | return '' |
---|
| 135 | return self.view.url(self.view.context, self.target) |
---|
| 136 | |
---|
[13380] | 137 | class StudentPassportActionButton(StudentPassportActionButton): |
---|
| 138 | """Inherit from same class in base package, not from kofacustom.nigeria |
---|
| 139 | which requires that no application slip exists. |
---|
| 140 | """ |
---|
[14207] | 141 | |
---|
| 142 | class CustomStudyCourseTranscriptActionButton(StudyCourseTranscriptActionButton): |
---|
[14315] | 143 | #grok.require('waeup.viewStudent') |
---|
[14207] | 144 | grok.name('transcript') |
---|
| 145 | |
---|
| 146 | class CustomTranscriptSlipActionButton(TranscriptSlipActionButton): |
---|
[14315] | 147 | #grok.require('waeup.viewStudent') |
---|
[14207] | 148 | grok.name('transcript_slip') |
---|
[14288] | 149 | |
---|
[16967] | 150 | class TranscriptStudviewSlipActionButton(CustomTranscriptSlipActionButton): |
---|
| 151 | #grok.require('waeup.viewStudent') |
---|
| 152 | grok.name('transcript_slip_studview') |
---|
| 153 | target = 'transcript_studview.pdf' |
---|
| 154 | text = _('Academic Transcript (Student View)') |
---|
| 155 | |
---|
[15330] | 156 | class StudyLevelRepairActionButton(ManageActionButton): |
---|
| 157 | grok.order(2) |
---|
| 158 | grok.context(IStudentStudyLevel) |
---|
| 159 | grok.view(StudyLevelDisplayFormPage) |
---|
| 160 | grok.require('waeup.editStudyLevel') |
---|
| 161 | text = _('Repair course list') |
---|
| 162 | target = 'repair' |
---|
| 163 | icon = 'actionicon_repair1.png' |
---|
| 164 | |
---|
| 165 | @property |
---|
| 166 | def target_url(self): |
---|
| 167 | try: |
---|
| 168 | studylevel_repair_enabled = grok.getSite()['configuration'][ |
---|
| 169 | str(self.context.level_session)].studylevel_repair_enabled |
---|
| 170 | except KeyError: |
---|
| 171 | return '' |
---|
[15340] | 172 | if not studylevel_repair_enabled \ |
---|
| 173 | or self.context.student.studycourse_locked: |
---|
[15330] | 174 | return '' |
---|
| 175 | return self.view.url(self.view.context, self.target) |
---|