[7191] | 1 | ## $Id: payments.py 7599 2012-02-07 11:30:00Z 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 | """ |
---|
[7599] | 19 | Student payment components. |
---|
[6635] | 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.component.interfaces import IFactory |
---|
[6875] | 23 | from zope.interface import implementedBy |
---|
[6877] | 24 | from waeup.sirp.students.interfaces import ( |
---|
| 25 | IStudentPaymentsContainer, IStudentNavigation, IStudentOnlinePayment) |
---|
[6875] | 26 | from waeup.sirp.payments import PaymentsContainer, OnlinePayment |
---|
[6635] | 27 | from waeup.sirp.utils.helpers import attrs_to_fields |
---|
| 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): |
---|
| 55 | return self.__parent__.__parent__ |
---|
| 56 | |
---|
| 57 | StudentOnlinePayment = attrs_to_fields(StudentOnlinePayment) |
---|
| 58 | |
---|
| 59 | # Student online payments must be importable. So we might need a factory. |
---|
| 60 | class StudentOnlinePaymentFactory(grok.GlobalUtility): |
---|
| 61 | """A factory for student online payments. |
---|
| 62 | """ |
---|
| 63 | grok.implements(IFactory) |
---|
| 64 | grok.name(u'waeup.StudentOnlinePayment') |
---|
| 65 | title = u"Create a new online payment.", |
---|
| 66 | description = u"This factory instantiates new online payment instances." |
---|
| 67 | |
---|
| 68 | def __call__(self, *args, **kw): |
---|
| 69 | return StudentOnlinePayment() |
---|
| 70 | |
---|
| 71 | def getInterfaces(self): |
---|
| 72 | return implementedBy(StudentOnlinePayment) |
---|