Changeset 12754


Ignore:
Timestamp:
12 Mar 2015, 20:17:34 (10 years ago)
Author:
uli
Message:

Add a breadcrumb for payments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/browser/breadcrumbs.py

    r12525 r12754  
    3030    ICompany, IUsersContainer, IDataCenter,
    3131    )
     32from waeup.ikoba.payments.interfaces import IPayment
     33from waeup.ikoba.payments.payment import find_payable_from_payable_id
    3234from waeup.ikoba.reports import IReportsContainer
    3335
     
    148150    parent_viewname = 'administration'
    149151    target = None
     152
     153
     154class PaymentBreadcrumb(Breadcrumb):
     155    """A breadcrumb for payment.
     156    """
     157    grok.context(IPayment)
     158    parent = grok.getSite()
     159    target = None
     160
     161    @property
     162    def title(self):
     163        id_part = self.context.payment_id[4:12]
     164        return _(u"Payment ${id}", mapping={'id': id_part})
     165
     166    @property
     167    def parent(self):
     168        """We display the payments payable as parent.
     169        """
     170        payment = self.context
     171        payable = find_payable_from_payable_id(payment.payable_id)
     172        if payable is None:
     173            # fallback: display site home as parent
     174            return (grok.getSite(), 'index')
     175        return (payable, 'index')
     176
    150177
    151178def getBreadcrumb(obj, viewname=None):
Note: See TracChangeset for help on using the changeset viewer.