[7191] | 1 | ## $Id: payments.py 8368 2012-05-06 12:32:23Z uli $ |
---|
| 2 | ## |
---|
[6635] | 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 | """ |
---|
[7599] | 19 | Student payment components. |
---|
[6635] | 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.component.interfaces import IFactory |
---|
[6875] | 23 | from zope.interface import implementedBy |
---|
[7811] | 24 | from waeup.kofa.students.interfaces import ( |
---|
[6877] | 25 | IStudentPaymentsContainer, IStudentNavigation, IStudentOnlinePayment) |
---|
[7811] | 26 | from waeup.kofa.payments import PaymentsContainer, OnlinePayment |
---|
| 27 | from waeup.kofa.utils.helpers import attrs_to_fields |
---|
[6635] | 28 | |
---|
[6860] | 29 | class StudentPaymentsContainer(PaymentsContainer): |
---|
[6635] | 30 | """This is a container for student payments. |
---|
| 31 | """ |
---|
[6860] | 32 | grok.implements(IStudentPaymentsContainer, IStudentNavigation) |
---|
| 33 | grok.provides(IStudentPaymentsContainer) |
---|
[6635] | 34 | |
---|
| 35 | def __init__(self): |
---|
[6860] | 36 | super(StudentPaymentsContainer, self).__init__() |
---|
[6635] | 37 | return |
---|
| 38 | |
---|
[6642] | 39 | def getStudent(self): |
---|
| 40 | return self.__parent__ |
---|
| 41 | |
---|
[6875] | 42 | StudentPaymentsContainer = attrs_to_fields(StudentPaymentsContainer) |
---|
| 43 | |
---|
| 44 | class StudentOnlinePayment(OnlinePayment): |
---|
| 45 | """This is an online payment. |
---|
| 46 | """ |
---|
[6877] | 47 | grok.implements(IStudentOnlinePayment, IStudentNavigation) |
---|
| 48 | grok.provides(IStudentOnlinePayment) |
---|
[6875] | 49 | |
---|
| 50 | def __init__(self): |
---|
| 51 | super(StudentOnlinePayment, self).__init__() |
---|
| 52 | return |
---|
| 53 | |
---|
| 54 | def getStudent(self): |
---|
[8368] | 55 | try: |
---|
| 56 | return self.__parent__.__parent__ |
---|
| 57 | except AttributeError: |
---|
| 58 | return None |
---|
[6875] | 59 | |
---|
| 60 | StudentOnlinePayment = attrs_to_fields(StudentOnlinePayment) |
---|
| 61 | |
---|
| 62 | # Student online payments must be importable. So we might need a factory. |
---|
| 63 | class StudentOnlinePaymentFactory(grok.GlobalUtility): |
---|
| 64 | """A factory for student online payments. |
---|
| 65 | """ |
---|
| 66 | grok.implements(IFactory) |
---|
| 67 | grok.name(u'waeup.StudentOnlinePayment') |
---|
| 68 | title = u"Create a new online payment.", |
---|
| 69 | description = u"This factory instantiates new online payment instances." |
---|
| 70 | |
---|
| 71 | def __call__(self, *args, **kw): |
---|
| 72 | return StudentOnlinePayment() |
---|
| 73 | |
---|
| 74 | def getInterfaces(self): |
---|
[7811] | 75 | return implementedBy(StudentOnlinePayment) |
---|