[9526] | 1 | ## $Id: viewlets.py 14616 2017-03-09 10:42:42Z 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 | |
---|
[10691] | 19 | import grok |
---|
[12907] | 20 | from zope.component import getUtility |
---|
[9873] | 21 | from waeup.kofa.students.viewlets import ( |
---|
[10691] | 22 | AddPreviousPaymentActionButton, AddBalancePaymentActionButton, |
---|
| 23 | ManageActionButton) |
---|
[12907] | 24 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
[10691] | 25 | from waeup.kofa.students.browser import StudentBaseDisplayFormPage |
---|
| 26 | from waeup.kofa.students.workflow import ( |
---|
| 27 | ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, |
---|
| 28 | VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE) |
---|
| 29 | from waeup.kwarapoly.interfaces import MessageFactory as _ |
---|
[9526] | 30 | |
---|
| 31 | class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): |
---|
| 32 | |
---|
| 33 | @property |
---|
| 34 | def target_url(self): |
---|
| 35 | return '' |
---|
[9873] | 36 | |
---|
[14616] | 37 | #class AddBalancePaymentActionButton(AddBalancePaymentActionButton): |
---|
[9873] | 38 | |
---|
[14616] | 39 | # @property |
---|
| 40 | # def target_url(self): |
---|
| 41 | # return '' |
---|
[10691] | 42 | |
---|
| 43 | class AdmissionNotificationActionButton(ManageActionButton): |
---|
| 44 | grok.order(4) |
---|
| 45 | grok.context(IStudent) |
---|
| 46 | grok.view(StudentBaseDisplayFormPage) |
---|
| 47 | grok.require('waeup.viewStudent') |
---|
| 48 | icon = 'actionicon_pdf.png' |
---|
| 49 | text = _('Download admission notification') |
---|
| 50 | target = 'admission_notification.pdf' |
---|
| 51 | |
---|
| 52 | @property |
---|
| 53 | def target_url(self): |
---|
| 54 | if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): |
---|
| 55 | return '' |
---|
| 56 | return self.view.url(self.view.context, self.target) |
---|
| 57 | |
---|
| 58 | class AdmissionSlipActionButton(ManageActionButton): |
---|
| 59 | grok.order(4) |
---|
| 60 | grok.context(IStudent) |
---|
| 61 | grok.view(StudentBaseDisplayFormPage) |
---|
| 62 | grok.require('waeup.viewStudent') |
---|
| 63 | icon = 'actionicon_pdf.png' |
---|
| 64 | text = _('Download admission letter') |
---|
| 65 | target = 'admission_slip.pdf' |
---|
| 66 | |
---|
| 67 | @property |
---|
| 68 | def target_url(self): |
---|
| 69 | if self.context.state in (CREATED, ADMITTED, |
---|
| 70 | CLEARANCE, REQUESTED, CLEARED): |
---|
| 71 | return '' |
---|
[10695] | 72 | return self.view.url(self.view.context, self.target) |
---|
| 73 | |
---|
[10705] | 74 | class RegistrationSlipActionButton(ManageActionButton): |
---|
[10695] | 75 | grok.order(4) |
---|
| 76 | grok.context(IStudent) |
---|
| 77 | grok.view(StudentBaseDisplayFormPage) |
---|
| 78 | grok.require('waeup.viewStudent') |
---|
| 79 | icon = 'actionicon_pdf.png' |
---|
| 80 | text = _('Download registration form') |
---|
[10705] | 81 | target = 'registration_slip.pdf' |
---|
[10695] | 82 | |
---|
| 83 | @property |
---|
| 84 | def target_url(self): |
---|
[11931] | 85 | if self.context.state in (CREATED,ADMITTED, |
---|
| 86 | CLEARANCE, REQUESTED, CLEARED): |
---|
[10695] | 87 | return '' |
---|
[12907] | 88 | return self.view.url(self.view.context, self.target) |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | class GetMatricNumberActionButton(ManageActionButton): |
---|
| 92 | grok.order(10) |
---|
| 93 | grok.context(IStudent) |
---|
| 94 | grok.view(StudentBaseDisplayFormPage) |
---|
| 95 | grok.require('waeup.viewStudent') |
---|
| 96 | icon = 'actionicon_count.png' |
---|
| 97 | text = _('Get Matriculation Number') |
---|
| 98 | |
---|
| 99 | @property |
---|
| 100 | def target_url(self): |
---|
| 101 | students_utils = getUtility(IStudentsUtils) |
---|
| 102 | if self.context.matric_number: |
---|
| 103 | return '' |
---|
| 104 | error, matric_number = students_utils.constructMatricNumber( |
---|
| 105 | self.context) |
---|
| 106 | if error: |
---|
| 107 | return '' |
---|
| 108 | return self.view.url(self.view.context, 'get_matric_number') |
---|