1 | ## $Id: viewlets.py 12975 2015-05-21 17:05: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 | |
---|
19 | import grok |
---|
20 | from zope.component import getUtility |
---|
21 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
22 | from waeup.kofa.students.workflow import PAID |
---|
23 | from waeup.kofa.students.viewlets import ( |
---|
24 | AddPreviousPaymentActionButton, AddBalancePaymentActionButton, |
---|
25 | ManageActionButton, StudentBaseDisplayFormPage) |
---|
26 | |
---|
27 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
28 | |
---|
29 | class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): |
---|
30 | |
---|
31 | @property |
---|
32 | def target_url(self): |
---|
33 | return '' |
---|
34 | |
---|
35 | class AddBalancePaymentActionButton(AddBalancePaymentActionButton): |
---|
36 | |
---|
37 | @property |
---|
38 | def target_url(self): |
---|
39 | return '' |
---|
40 | |
---|
41 | class GetMatricNumberActionButton(ManageActionButton): |
---|
42 | grok.order(10) |
---|
43 | grok.context(IStudent) |
---|
44 | grok.view(StudentBaseDisplayFormPage) |
---|
45 | grok.require('waeup.viewStudent') |
---|
46 | #grok.require('waeup.manageStudent') |
---|
47 | icon = 'actionicon_count.png' |
---|
48 | text = _('Get Matriculation Number') |
---|
49 | |
---|
50 | @property |
---|
51 | def target_url(self): |
---|
52 | students_utils = getUtility(IStudentsUtils) |
---|
53 | if self.context.matric_number: |
---|
54 | return '' |
---|
55 | error, matric_number = students_utils.constructMatricNumber( |
---|
56 | self.context) |
---|
57 | if error: |
---|
58 | return '' |
---|
59 | return self.view.url(self.view.context, 'get_matric_number') |
---|
60 | |
---|
61 | class MatricNumberSlipActionButton(ManageActionButton): |
---|
62 | grok.order(10) |
---|
63 | grok.context(IStudent) |
---|
64 | grok.view(StudentBaseDisplayFormPage) |
---|
65 | grok.require('waeup.viewStudent') |
---|
66 | icon = 'actionicon_pdf.png' |
---|
67 | text = _('Download matriculation number slip') |
---|
68 | target = 'matric_number_slip.pdf' |
---|
69 | |
---|
70 | @property |
---|
71 | def target_url(self): |
---|
72 | if self.context.state not in (PAID,) or not self.context.is_fresh \ |
---|
73 | or not self.context.matric_number: |
---|
74 | return '' |
---|
75 | return self.view.url(self.view.context, self.target) |
---|