Ignore:
Timestamp:
14 Mar 2015, 15:40:54 (10 years ago)
Author:
Henrik Bettermann
Message:

Add PaymentsContainerManagePage?.

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

Legend:

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

    r12762 r12763  
    127127            self.flash(_('No payment found.'), type="warning")
    128128        return
     129
     130
     131class PaymentsContainerManagePage(IkobaPage):
     132    """The manage page for payment containers.
     133    """
     134    grok.context(IPaymentsContainer)
     135    grok.name('manage')
     136    grok.require('waeup.managePortal')
     137    grok.template('containermanagepage')
     138    pnav = 5
     139    label = _('Manage payment section')
     140    search_button = _('Find payments(s)')
     141    remove_button = _('Remove selected')
     142
     143    @property
     144    def gateway_services(self):
     145        return get_payment_providers()
     146
     147    @property
     148    def payment_states(self):
     149        return payment_states
     150
     151    def update(self, *args, **kw):
     152        form = self.request.form
     153        self.hitlist = []
     154        if 'searchterm' in form and form['searchterm']:
     155            self.searchterm = form['searchterm']
     156            self.searchtype = form['searchtype']
     157        elif 'old_searchterm' in form:
     158            self.searchterm = form['old_searchterm']
     159            self.searchtype = form['old_searchtype']
     160        else:
     161            if 'search' in form:
     162                self.flash(_('Empty search string'), type="warning")
     163            return
     164        if not 'entries' in form:
     165            self.hitlist = search(query=self.searchterm,
     166                searchtype=self.searchtype)
     167            if not self.hitlist:
     168                self.flash(_('No payment found.'), type="warning")
     169            if 'remove' in form:
     170                self.flash(_('No item selected.'), type="warning")
     171            return
     172        entries = form['entries']
     173        if isinstance(entries, basestring):
     174            entries = [entries]
     175        deleted = []
     176        for entry in entries:
     177            if 'remove' in form:
     178                del self.context[entry]
     179                deleted.append(entry)
     180        self.hitlist = search(query=self.searchterm,
     181            searchtype=self.searchtype)
     182        if len(deleted):
     183            self.flash(_('Successfully removed: ${a}',
     184                mapping={'a': ','.join(deleted)}))
     185        return
Note: See TracChangeset for help on using the changeset viewer.