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