source: main/waeup.kofa/trunk/src/waeup/kofa/payments/payment.py @ 8183

Last change on this file since 8183 was 8182, checked in by Henrik Bettermann, 13 years ago

Part 1: Add tzinfo to all persistent datetime objects.

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1## $Id: payment.py 8182 2012-04-16 20:56:59Z 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"""
19These are the payment tickets.
20"""
21import grok
22from datetime import datetime
23from grok import index
24from zope.component import getUtility
25from waeup.kofa.interfaces import IKofaUtils
26from waeup.kofa.payments.interfaces import (
27    IPayment, ISCPayment, IOnlinePayment,
28    payment_states, payment_categories)
29from waeup.kofa.utils.helpers import attrs_to_fields
30
31class 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        try:
41            tz = getUtility(IKofaUtils).tzinfo
42        except:
43            #In unit tests KofaUtils is not available.
44            tz = None
45        self.creation_date = datetime.now(tz)
46        self.p_id = None
47        return
48
49    @property
50    def state(self):
51        return payment_states.getTermByToken(self.p_state).title
52
53    @property
54    def category(self):
55        return payment_categories.getTermByToken(self.p_category).title
56
57class SCPayment(Payment):
58    """This is a scratch card payment.
59    """
60    grok.implements(ISCPayment)
61    grok.provides(ISCPayment)
62
63    def __init__(self):
64        super(SCPayment, self).__init__()
65        p_id = None
66        return
67
68SCPayment = attrs_to_fields(SCPayment)
69
70class OnlinePayment(Payment):
71    """This is an online payment.
72    """
73    grok.implements(IOnlinePayment)
74    grok.provides(IOnlinePayment)
75
76    def __init__(self):
77        super(OnlinePayment, self).__init__()
78        p_id = None
79        return
80
81OnlinePayment = attrs_to_fields(OnlinePayment)
Note: See TracBrowser for help on using the repository browser.