Changeset 12762 for main/waeup.ikoba/trunk/src/waeup/ikoba/payments
- Timestamp:
- 14 Mar 2015, 13:49:29 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/payments
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/browser.py
r12761 r12762 20 20 import grok 21 21 from waeup.ikoba.browser.breadcrumbs import Breadcrumb 22 from waeup.ikoba.interfaces import IIkobaObject 22 23 from 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 24 from waeup.ikoba.browser.viewlets import PrimaryNavTab 25 from waeup.ikoba.browser.layout import ( 26 IkobaPage, IkobaEditFormPage, IkobaDisplayFormPage, 27 NullValidator, jsaction, action, UtilityView) 28 from waeup.ikoba.utils.helpers import get_current_principal 29 30 from waeup.ikoba.payments.interfaces import ( 31 IPaymentsContainer, IPayment, payment_states 32 ) 33 from waeup.ikoba.payments.payment import ( 34 find_payable_from_payable_id, 35 get_payment_providers 36 ) 37 from waeup.ikoba.payments.catalog import search 38 39 40 grok.context(IIkobaObject) # Make IIkobaObject the default context 41 grok.templatedir('templates') 42 43 44 class 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 61 class PaymentsBreadcrumb(Breadcrumb): 62 """A breadcrumb for the payments container. 63 """ 64 grok.context(IPaymentsContainer) 65 title = _('Payments') 66 25 67 26 68 class PaymentBreadcrumb(Breadcrumb): … … 46 88 return (grok.getSite(), 'index') 47 89 return (payable, 'index') 90 91 92 class 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 19 19 """ 20 20 import grok 21 from hurry.query import Eq, Text 22 from hurry.query.query import Query 23 from zope.catalog.interfaces import ICatalog 24 from zope.component import queryUtility 21 25 from waeup.ikoba.interfaces import ICompany 22 from waeup.ikoba.payments.interfaces import IPayment 26 from waeup.ikoba.payments.interfaces import ( 27 IPayment, IPayable 28 ) 29 from waeup.ikoba.payments.payment import ( 30 find_payable_from_payable_id 31 ) 32 33 34 def 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 23 52 24 53 … … 32 61 payment_id = grok.index.Field(attribute='payment_id') 33 62 payer_id = grok.index.Field(attribute='payer_id') 63 payable_id = grok.index.Field(attribute='payable_id') 34 64 state = grok.index.Field(attribute='state') 35 65 amount = grok.index.Field(attribute='amount')
Note: See TracChangeset for help on using the changeset viewer.