- Timestamp:
- 5 Mar 2015, 07:28:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12634 r12663 60 60 ) 61 61 from waeup.ikoba.customers.catalog import search 62 from waeup.ikoba.customers.workflow import PAYMENT_TRANSITIONS 62 63 63 64 grok.context(IIkobaObject) … … 1446 1447 grok.require('waeup.handleCustomer') 1447 1448 1449 def submission_allowed(self, action=None): 1450 if self.context.state == CREATED and not self.context.fee_based: 1451 return True 1452 return False 1453 1454 def payment_expected(self, action=None): 1455 if self.context.state == CREATED and self.context.fee_based: 1456 return True 1457 return False 1458 1448 1459 @property 1449 1460 def form_fields(self): … … 1456 1467 return 1457 1468 1458 @action(_('Apply now (final submit)'), warning=WARNING_CON) 1459 def finalsubmit(self, **data): 1469 @action(_('Apply now (final submission)'), warning=WARNING_CON, 1470 condition=submission_allowed, style='primary') 1471 def submit(self, **data): 1460 1472 if self.terms_and_conditions and not self.request.form.get( 1461 1473 'confirm_tc', False): … … 1466 1478 msave(self, **data) 1467 1479 IWorkflowInfo(self.context).fireTransition('submit') 1468 self.flash(_(' Form has been submitted.'))1480 self.flash(_('Application form has been submitted.')) 1469 1481 self.redirect(self.url(self.context)) 1470 1482 return 1471 1483 1484 @action(_('Proceed to checkout'), 1485 condition=payment_expected, style='primary') 1486 def proceed_checkout(self, **data): 1487 if self.terms_and_conditions and not self.request.form.get( 1488 'confirm_tc', False): 1489 self.flash(_('Please read the terms and conditions and ' 1490 'confirm your acceptance of these by ticking ' 1491 'the confirmation box.'), type="danger") 1492 return 1493 msave(self, **data) 1494 self.redirect(self.url(self.context, 'select_payment_method')) 1495 return 1496 1497 1498 class SelectPaymentMethodPage(IkobaEditFormPage): 1499 """ Page to to select payment method 1500 """ 1501 grok.context(IContract) 1502 grok.name('select_payment_method') 1503 grok.require('waeup.handleCustomer') 1504 grok.template('selectpaymentmethodpage') 1505 pnav = 4 1506 label = _('Select payment method') 1507 1508 def update(self, CANCEL=None): 1509 if self.context.state != CREATED or not self.context.fee_based: 1510 emit_lock_message(self) 1511 return 1512 super(SelectPaymentMethodPage, self).update() 1513 return 1514 1515 @action(_('Select payment method and proceed to payment gateway (final submission)'), 1516 style='primary', warning=WARNING_CON,) 1517 def confirm(self, **data): 1518 IWorkflowInfo(self.context).fireTransition('await') 1519 self.flash(_('Payment has been initiated.')) 1520 return 1472 1521 1473 1522 class ContractTriggerTransitionFormPage(IkobaEditFormPage): … … 1493 1542 wf_info = IWorkflowInfo(self.context) 1494 1543 allowed_transitions = [t for t in wf_info.getManualTransitions()] 1544 # Skip payment transitions if total amount is zero 1545 if not self.context.fee_based: 1546 allowed_transitions = [t for t in allowed_transitions 1547 if not t[0] in PAYMENT_TRANSITIONS] 1495 1548 return [dict(name='', title=_('No transition'))] +[ 1496 1549 dict(name=x, title=y) for x, y in allowed_transitions]
Note: See TracChangeset for help on using the changeset viewer.