source: main/waeup.ikoba/trunk/src/waeup/ikoba/payments/browser.py @ 12761

Last change on this file since 12761 was 12761, checked in by Henrik Bettermann, 10 years ago

Add browser module in payments. We need this module for payments management.

Move breadcrumbs PaymentBreadcrumb? into this module.

File size: 1.7 KB
Line 
1## $Id: browser.py 12760 2015-03-14 05:46:24Z henrik $
2##
3## Copyright (C) 2015 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"""UI components for payments.
19"""
20import grok
21from waeup.ikoba.browser.breadcrumbs import Breadcrumb
22from waeup.ikoba.interfaces import MessageFactory as _
23from waeup.ikoba.payments.interfaces import IPayment
24from waeup.ikoba.payments.payment import find_payable_from_payable_id
25
26class PaymentBreadcrumb(Breadcrumb):
27    """A breadcrumb for payment.
28    """
29    grok.context(IPayment)
30    parent = grok.getSite()
31    target = None
32
33    @property
34    def title(self):
35        id_part = self.context.payment_id[4:12]
36        return _(u"Payment ${id}", mapping={'id': id_part})
37
38    @property
39    def parent(self):
40        """We display the payments payable as parent.
41        """
42        payment = self.context
43        payable = find_payable_from_payable_id(payment.payable_id)
44        if payable is None:
45            # fallback: display site home as parent
46            return (grok.getSite(), 'index')
47        return (payable, 'index')
Note: See TracBrowser for help on using the repository browser.