[7195] | 1 | ## $Id: payment.py 7811 2012-03-08 19:00:51Z uli $ |
---|
| 2 | ## |
---|
[6864] | 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 | These are the payment tickets. |
---|
| 20 | """ |
---|
| 21 | import grok |
---|
[6869] | 22 | from datetime import datetime |
---|
[6864] | 23 | from grok import index |
---|
[7811] | 24 | from waeup.kofa.payments.interfaces import ( |
---|
[7627] | 25 | IPayment, ISCPayment, IOnlinePayment, |
---|
| 26 | payment_states, payment_categories) |
---|
[7811] | 27 | from waeup.kofa.utils.helpers import attrs_to_fields |
---|
[6864] | 28 | |
---|
| 29 | class Payment(grok.Container): |
---|
| 30 | """This is a payment. |
---|
| 31 | """ |
---|
| 32 | grok.implements(IPayment) |
---|
| 33 | grok.provides(IPayment) |
---|
| 34 | grok.baseclass() |
---|
| 35 | |
---|
| 36 | def __init__(self): |
---|
| 37 | super(Payment, self).__init__() |
---|
[6869] | 38 | self.creation_date = datetime.now() |
---|
| 39 | self.p_id = None |
---|
[6864] | 40 | return |
---|
| 41 | |
---|
[6869] | 42 | @property |
---|
| 43 | def state(self): |
---|
| 44 | return payment_states.getTermByToken(self.p_state).title |
---|
| 45 | |
---|
| 46 | @property |
---|
| 47 | def category(self): |
---|
| 48 | return payment_categories.getTermByToken(self.p_category).title |
---|
| 49 | |
---|
[6864] | 50 | class SCPayment(Payment): |
---|
| 51 | """This is a scratch card payment. |
---|
| 52 | """ |
---|
| 53 | grok.implements(ISCPayment) |
---|
| 54 | grok.provides(ISCPayment) |
---|
| 55 | |
---|
| 56 | def __init__(self): |
---|
| 57 | super(SCPayment, self).__init__() |
---|
[6869] | 58 | p_id = None |
---|
[6864] | 59 | return |
---|
| 60 | |
---|
| 61 | SCPayment = attrs_to_fields(SCPayment) |
---|
| 62 | |
---|
| 63 | class OnlinePayment(Payment): |
---|
| 64 | """This is an online payment. |
---|
| 65 | """ |
---|
| 66 | grok.implements(IOnlinePayment) |
---|
| 67 | grok.provides(IOnlinePayment) |
---|
| 68 | |
---|
| 69 | def __init__(self): |
---|
| 70 | super(OnlinePayment, self).__init__() |
---|
[6869] | 71 | p_id = None |
---|
[6864] | 72 | return |
---|
| 73 | |
---|
[7811] | 74 | OnlinePayment = attrs_to_fields(OnlinePayment) |
---|