Changeset 12663 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 5 Mar 2015, 07:28:31 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 1 added
- 10 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] -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py
r12633 r12663 161 161 return 162 162 163 @property 164 def fee_based(self): 165 if self.product_options: 166 amount = 0 167 for option in self.product_options: 168 amount += option.fee 169 if amount: 170 return True 171 return False 172 163 173 164 174 class SampleContract(ContractBase): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12633 r12663 303 303 valid_from = Attribute('Contract valid from') 304 304 valid_to = Attribute('Contract valid to') 305 fee_based = Attribute('Fee based contract') 305 306 306 307 contract_id = schema.TextLine( -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/reports/contract_statistics.py
r12660 r12663 22 22 from zope.interface import implementer, Interface, Attribute 23 23 from waeup.ikoba.interfaces import ( 24 IIkobaUtils, CREATED, APPROVED, SUBMITTED, EXPIRED, REJECTED) 24 IIkobaUtils, 25 CREATED, APPROVED, 26 SUBMITTED, EXPIRED, 27 REJECTED, AWAITING) 25 28 from waeup.ikoba.customers.interfaces import ICustomersUtils 26 29 from waeup.ikoba.interfaces import MessageFactory as _ … … 54 57 types = TYPES.keys() 55 58 type_names = tuple(TYPES.values()) + (u'All',) 56 states = (CREATED, SUBMITTED, APPROVED, EXPIRED, REJECTED)59 states = (CREATED, AWAITING, SUBMITTED, APPROVED, EXPIRED, REJECTED) 57 60 STATES = getUtility(ICustomersUtils).TRANSLATED_CONTRACT_STATES 58 61 state_names = tuple([STATES[state] for state in states]) + (u'Total',) … … 108 111 ('LINEAFTER', (-1,0), (-1,-1), 0.25, colors.black), 109 112 ('LINEBEFORE', (-1,0), (-1,-1), 1.0, colors.black), 110 #('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black),113 ('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black), 111 114 #('LINEABOVE', (0,0), (-1,0), 0.25, colors.black), 112 115 ] -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/reports/tests/test_contract_statistics.py
r12659 r12663 17 17 layer = FunctionalLayer 18 18 19 states = ('created', 'submitted for approval', 'approved', 'expired', 19 states = ('created', 'awaiting payment', 20 'submitted for approval', 21 'approved', 'expired', 20 22 'rejected', 'Total') 21 23 … … 34 36 ((u'Sample Contract', u'All'), 35 37 self.states, 36 ((1, 0, 0, 0, 0, 1),37 (1, 0, 0, 0, 0, 1),))38 ((1, 0, 0, 0, 0, 0, 1), 39 (1, 0, 0, 0, 0, 0, 1),)) 38 40 ) 39 41 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12634 r12663 1417 1417 # The form is also saved. 1418 1418 self.browser.getLink("Edit").click() 1419 self.browser.getControl(" Apply").click()1419 self.browser.getControl("Proceed to checkout").click() 1420 1420 self.assertTrue('confirm your acceptance of these by ticking' in self.browser.contents) 1421 1421 self.assertEqual(contract.state, 'created') 1422 1422 self.browser.getControl(name="confirm_tc").value = True 1423 self.browser.getControl("Apply").click() 1424 self.assertEqual(contract.state, 'submitted') 1425 self.assertTrue('Contract State: submitted for approval' in self.browser.contents) 1423 self.browser.getControl("Proceed to checkout").click() 1424 self.assertEqual(contract.state, 'created') 1425 self.browser.getControl("Select payment method").click() 1426 self.assertEqual(contract.state, 'awaiting') 1426 1427 # Customer can't edit the contract once it has been submitted 1427 1428 self.browser.open(self.contracts_path + '/%s/edit' % conid) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r12633 r12663 256 256 result, 257 257 'class_name,comment,contract_category,contract_id,document_object,' 258 ' history,last_product_id,'259 'product_object,product_options,state,tc_dict,title, user_id,'260 ' valid_from,valid_to\r\n'261 262 'SampleContract,,sample,CON1,, [],,,[],,{},,,,\r\n'258 'fee_based,history,last_product_id,' 259 'product_object,product_options,state,tc_dict,title,' 260 'user_id,valid_from,valid_to\r\n' 261 262 'SampleContract,,sample,CON1,,0,[],,,[],,{},,,,\r\n' 263 263 ) 264 264 return … … 273 273 self.assertMatches( 274 274 'class_name,comment,contract_category,contract_id,document_object,' 275 ' history,last_product_id,'276 'product_object,product_options,state,tc_dict,title, user_id,'277 ' valid_from,valid_to\r\n'278 279 'SampleContract,,sample,CON1,DOC1, [u\'2014-12-04 12:10:46 UTC - '275 'fee_based,history,last_product_id,' 276 'product_object,product_options,state,tc_dict,title,' 277 'user_id,valid_from,valid_to\r\n' 278 279 'SampleContract,,sample,CON1,DOC1,1,[u\'2014-12-04 12:10:46 UTC - ' 280 280 'Contract created by system\'],,' 281 281 'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",' … … 295 295 self.assertMatches( 296 296 'class_name,comment,contract_category,contract_id,document_object,' 297 ' history,last_product_id,'298 'product_object,product_options,state,tc_dict,title, user_id,'299 ' valid_from,valid_to\r\n'300 301 'SampleContract,,sample,CON1,DOC1, [u\'2014-12-04 12:10:46 UTC - '297 'fee_based,history,last_product_id,' 298 'product_object,product_options,state,tc_dict,title,' 299 'user_id,valid_from,valid_to\r\n' 300 301 'SampleContract,,sample,CON1,DOC1,1,[u\'2014-12-04 12:10:46 UTC - ' 302 302 'Contract created by system\'],,' 303 303 'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",' … … 317 317 self.assertMatches( 318 318 'class_name,comment,contract_category,contract_id,document_object,' 319 ' history,last_product_id,'320 'product_object,product_options,state,tc_dict,title, user_id,'321 ' valid_from,valid_to\r\n'322 323 'SampleContract,,sample,CON1,DOC1, [u\'2014-12-04 12:10:46 UTC - '319 'fee_based,history,last_product_id,' 320 'product_object,product_options,state,tc_dict,title,' 321 'user_id,valid_from,valid_to\r\n' 322 323 'SampleContract,,sample,CON1,DOC1,1,[u\'2014-12-04 12:10:46 UTC - ' 324 324 'Contract created by system\'],,' 325 325 'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",' -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12634 r12663 38 38 from waeup.ikoba.interfaces import ( 39 39 STARTED, CREATED, REQUESTED, APPROVED, SUBMITTED, VERIFIED, REJECTED, 40 EXPIRED, PROVISIONALLY, 40 EXPIRED, PROVISIONALLY, AWAITING, 41 41 IIkobaUtils, IExtFileStore) 42 42 from waeup.ikoba.customers.interfaces import ICustomersUtils … … 308 308 TRANSLATED_CONTRACT_STATES = { 309 309 CREATED: _('created'), 310 AWAITING: _('awaiting payment'), 310 311 SUBMITTED: _('submitted for approval'), 311 312 APPROVED: _('approved'), -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py
r12553 r12663 28 28 IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils, IUserAccount, 29 29 STARTED, CREATED, REQUESTED, PROVISIONALLY, APPROVED, 30 SUBMITTED, VERIFIED, REJECTED, EXPIRED )30 SUBMITTED, VERIFIED, REJECTED, EXPIRED, AWAITING) 31 31 from waeup.ikoba.interfaces import MessageFactory as _ 32 32 from waeup.ikoba.workflow import ( … … 191 191 192 192 Transition( 193 transition_id = 'await', 194 title = _('Initiate payment'), 195 source = CREATED, 196 condition = NullCondition, 197 msg = _('Payment initiated'), 198 destination = AWAITING), 199 200 Transition( 201 transition_id = 'discard', 202 title = _('Discard payment'), 203 source = AWAITING, 204 condition = NullCondition, 205 msg = _('Payment discarded'), 206 destination = CREATED), 207 208 Transition( 193 209 transition_id = 'submit', 194 210 title = _('Submit for approval'), … … 198 214 199 215 Transition( 216 transition_id = 'confirm', 217 title = _('Confirm payment'), 218 msg = _('Payment and submission confirmed'), 219 source = AWAITING, 220 destination = SUBMITTED), 221 222 Transition( 200 223 transition_id = 'approve', 201 224 title = _('Approve'), … … 245 268 source = EXPIRED, 246 269 destination = CREATED), 270 247 271 ) 272 273 PAYMENT_TRANSITIONS = ['await', 'discard', 'confirm'] 248 274 249 275 contract_workflow = IkobaWorkflow(CONTRACT_TRANSITIONS) … … 286 312 history = IObjectHistory(obj) 287 313 history.addMessage(msg) 288 if event.transition.transition_id not in ( 'create', 'submit') \289 and obj.customer:314 if event.transition.transition_id not in ( 315 'create', 'submit', 'confirm', 'await') and obj.customer: 290 316 ikoba_utils = getUtility(IIkobaUtils) 291 317 ikoba_utils.sendTransitionInfo(IUserAccount(obj.customer), obj, msg) -
main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py
r12607 r12663 55 55 56 56 SUBMITTED = 'submitted' 57 VERIFIED = 'verified'57 AWAITING = 'awaiting' 58 58 REJECTED = 'rejected' 59 59 EXPIRED = 'expired' 60 61 VERIFIED = 'verified' 60 62 PUBLISHED = 'published' 61 63
Note: See TracChangeset for help on using the changeset viewer.