Ignore:
Timestamp:
14 Mar 2015, 13:49:29 (10 years ago)
Author:
Henrik Bettermann
Message:

Add PaymentsContainerPage? to search for and list payments (work in progress, completely untested).

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
1 added
8 edited

Legend:

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

    r12540 r12762  
    4747And then change back to English by clicking on the third link containing 'en'
    4848behind 'Anfragen' and 'Einloggen'::
    49   >>> browser.getLink('en', index=2).click()
     49  >>> browser.getLink('en', index=3).click()
    5050  >>> print browser.contents
    5151  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12760 r12762  
    5050    payment_states
    5151    )
     52from waeup.ikoba.payments.catalog import search as search_payments
    5253from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget
    5354from waeup.ikoba.utils.helpers import (
     
    5960    IContractSelectProduct,
    6061    )
    61 from waeup.ikoba.customers.catalog import search
     62from waeup.ikoba.customers.catalog import search as search_customers
    6263from waeup.ikoba.customers.workflow import PAYMENT_TRANSITIONS
    6364
     
    160161                           type="danger")
    161162                return
    162         self.hitlist = search(query=self.searchterm,
     163        self.hitlist = search_customers(query=self.searchterm,
    163164            searchtype=self.searchtype, view=self)
    164165        if not self.hitlist:
     
    203204                return
    204205        if not 'entries' in form:
    205             self.hitlist = search(query=self.searchterm,
     206            self.hitlist = search_customers(query=self.searchterm,
    206207                searchtype=self.searchtype, view=self)
    207208            if not self.hitlist:
     
    218219                del self.context[entry]
    219220                deleted.append(entry)
    220         self.hitlist = search(query=self.searchterm,
     221        self.hitlist = search_customers(query=self.searchterm,
    221222            searchtype=self.searchtype, view=self)
    222223        if len(deleted):
     
    17291730
    17301731    def payments(self):
    1731         values = []
    1732         payable = None
    1733         for payment in get_payments_from_payer_id(
    1734             self.context.customer.customer_id):
    1735             payable_object = find_payable_from_payable_id(payment.payable_id)
    1736             if payable_object is not None:
    1737                 payable = IPayable(payable_object)
    1738             values.append((payment, payable, payable_object))
    1739         return values
     1732        return search_payments(
     1733            query=self.context.customer_id, searchtype='payer_id')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/paymentspage.pt

    r12757 r12762  
    11<br />
    2 <table class="ikoba-data-table dataTableManage">
     2<table class="ikoba-data-table dataTable">
    33  <thead>
    44  <tr>
     
    2020      <td tal:content="python: view.gateway_services[value[0].gateway_service].title">SERVICE</td>
    2121      <td tal:content="python: value[0].amount">AMOUNT</td>
    22       <td tal:content="python: value[0].currency">AMOUNT</td>
     22      <td tal:content="python: value[0].currency">CURRENCY</td>
    2323      <td tal:content="python: view.payment_states.getTerm(value[0].state).title">STATE</td>
    2424      <td>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12757 r12762  
    166166    text = _(u'Documents')
    167167
     168
    168169class CustomerManagePaymentsLink(CustomerManageLink):
    169170    grok.order(5)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_browser.py

    r12444 r12762  
    275275
    276276        # Documents can be removed
    277         self.browser.getLink("en", index=2).click()
     277        self.browser.getLink("en", index=3).click()
    278278        self.browser.getLink("Documents").click()
    279279        self.browser.getLink("Manage").click()
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/browser.py

    r12761 r12762  
    2020import grok
    2121from waeup.ikoba.browser.breadcrumbs import Breadcrumb
     22from waeup.ikoba.interfaces import IIkobaObject
    2223from waeup.ikoba.interfaces import MessageFactory as _
    23 from waeup.ikoba.payments.interfaces import IPayment
    24 from waeup.ikoba.payments.payment import find_payable_from_payable_id
     24from waeup.ikoba.browser.viewlets import PrimaryNavTab
     25from waeup.ikoba.browser.layout import (
     26    IkobaPage, IkobaEditFormPage, IkobaDisplayFormPage,
     27    NullValidator, jsaction, action, UtilityView)
     28from waeup.ikoba.utils.helpers import get_current_principal
     29
     30from waeup.ikoba.payments.interfaces import (
     31    IPaymentsContainer, IPayment, payment_states
     32    )
     33from waeup.ikoba.payments.payment import (
     34    find_payable_from_payable_id,
     35    get_payment_providers
     36    )
     37from waeup.ikoba.payments.catalog import search
     38
     39
     40grok.context(IIkobaObject)  # Make IIkobaObject the default context
     41grok.templatedir('templates')
     42
     43
     44class PaymentsTab(PrimaryNavTab):
     45    """Payments tab in primary navigation.
     46    """
     47
     48    grok.context(IIkobaObject)
     49    grok.order(3)
     50    grok.require('waeup.Public')
     51    grok.name('paymentstab')
     52
     53    pnav = 5
     54    tab_title = _(u'Payments')
     55
     56    @property
     57    def link_target(self):
     58        return self.view.application_url('payments')
     59
     60
     61class PaymentsBreadcrumb(Breadcrumb):
     62    """A breadcrumb for the payments container.
     63    """
     64    grok.context(IPaymentsContainer)
     65    title = _('Payments')
     66
    2567
    2668class PaymentBreadcrumb(Breadcrumb):
     
    4688            return (grok.getSite(), 'index')
    4789        return (payable, 'index')
     90
     91
     92class PaymentsContainerPage(IkobaPage):
     93    """The standard view for payment containers.
     94    """
     95    grok.context(IPaymentsContainer)
     96    grok.name('index')
     97    grok.require('waeup.managePortal')
     98    grok.template('containerpage')
     99    label = _('Find payments')
     100    search_button = _('Find payment(s)')
     101    pnav = 5
     102
     103    @property
     104    def gateway_services(self):
     105        return get_payment_providers()
     106
     107    @property
     108    def payment_states(self):
     109        return payment_states
     110
     111    def update(self, *args, **kw):
     112        form = self.request.form
     113        self.hitlist = []
     114        if 'searchterm' in form and form['searchterm']:
     115            self.searchterm = form['searchterm']
     116            self.searchtype = form['searchtype']
     117        elif 'old_searchterm' in form:
     118            self.searchterm = form['old_searchterm']
     119            self.searchtype = form['old_searchtype']
     120        else:
     121            if 'search' in form:
     122                self.flash(_('Empty search string'), type="warning")
     123            return
     124        self.hitlist = search(query=self.searchterm,
     125            searchtype=self.searchtype)
     126        if not self.hitlist:
     127            self.flash(_('No payment found.'), type="warning")
     128        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/catalog.py

    r12671 r12762  
    1919"""
    2020import grok
     21from hurry.query import Eq, Text
     22from hurry.query.query import Query
     23from zope.catalog.interfaces import ICatalog
     24from zope.component import queryUtility
    2125from waeup.ikoba.interfaces import ICompany
    22 from waeup.ikoba.payments.interfaces import IPayment
     26from waeup.ikoba.payments.interfaces import (
     27    IPayment, IPayable
     28    )
     29from waeup.ikoba.payments.payment import (
     30    find_payable_from_payable_id
     31    )
     32
     33
     34def search(query=None, searchtype=None):
     35    hitlist = []
     36    # Temporary solution to display all payments added
     37    if query == '*':
     38        cat = queryUtility(ICatalog, name='payments_catalog')
     39        results = cat.searchResults(payment_id=(None, None))
     40    else:
     41        results = Query().searchResults(
     42            Eq(('payments_catalog', searchtype), query))
     43    hitlist = []
     44    for payment in results:
     45        payable_object = find_payable_from_payable_id(payment.payable_id)
     46        if payable_object is not None:
     47            payable = IPayable(payable_object)
     48        else:
     49            payable = None
     50        hitlist.append((payment, payable, payable_object))
     51    return hitlist
    2352
    2453
     
    3261    payment_id = grok.index.Field(attribute='payment_id')
    3362    payer_id = grok.index.Field(attribute='payer_id')
     63    payable_id = grok.index.Field(attribute='payable_id')
    3464    state = grok.index.Field(attribute='state')
    3565    amount = grok.index.Field(attribute='amount')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/viewlets.py

    r12067 r12762  
    4242
    4343    grok.context(IIkobaObject)
    44     grok.order(1)
     44    grok.order(2)
    4545    grok.require('waeup.Public')
    4646    grok.name('productstab')
Note: See TracChangeset for help on using the changeset viewer.