Changeset 12723 for main


Ignore:
Timestamp:
10 Mar 2015, 16:18:57 (10 years ago)
Author:
uli
Message:

Use dynamic form buttons.

Location:
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/demo_provider.py

    r12711 r12723  
    11import grok
    22from waeup.ikoba.interfaces import MessageFactory as _
    3 from waeup.ikoba.browser.layout import IkobaPage
     3from waeup.ikoba.browser.layout import IkobaEditFormPage, action
    44from waeup.ikoba.payments.interfaces import IPaymentGatewayService, IPayment
    5 from waeup.ikoba.payments.payment import Payment, get_payment
     5from waeup.ikoba.payments.payment import (
     6    Payment, get_payment, find_payable_from_payable_id)
    67
    78
     
    4344
    4445
    45 class CreditCardStep1(IkobaPage):
     46class CreditCardStep1(IkobaEditFormPage):
    4647    grok.context(IPayment)
    4748    grok.name('demo_cc1')
     
    5455    def update(self):
    5556        pass
     57
     58    @action(_('Authorize Payment'), style="primary")
     59    def authorize(self, **data):
     60        print "AUTH!"
     61
     62    @action(_('Cancel'))
     63    def cancel(self, **data):
     64        """Go back to the payable (if possible) or site home.
     65        """
     66        payable_id = getattr(self.context, 'payable_id', '')
     67        payed_item = find_payable_from_payable_id(payable_id)
     68        self.flash(_("Payment cancelled."))
     69        if payed_item is not None:
     70            # remove context/payment?
     71            target = self.url(payed_item)
     72        else:
     73            target = grok.getSite()
     74        self.redirect(self.url(target))
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/templates/demo_cc_step1.pt

    r12708 r12723  
    126126    </div>
    127127  </div>
     128
    128129  <div class="form-group">
    129130    <div class="col-sm-offset-2 col-sm-10">
    130       <button type="submit" class="btn btn-primary">Authorize Payment</button>
    131       <button type="submit" class="btn">Cancel</button>
     131      <div tal:condition="view/availableActions">
     132        <input tal:repeat="action view/actions"
     133               tal:replace="structure action/render"
     134               />
     135      </div>
    132136    </div>
    133137  </div>
Note: See TracChangeset for help on using the changeset viewer.