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