- Timestamp:
- 15 Mar 2015, 13:02:49 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12741 r12768 37 37 38 38 39 # Define a validation method for product options 40 class CurrencyMismatch(schema.ValidationError): 41 __doc__ = u"Currency mismatch" 42 43 44 def unique_currency(value): 45 currencies = set([x.currency for x in value]) 46 if len(currencies) > 1: 47 raise CurrencyMismatch(value) 48 return True 49 50 39 51 class ICustomersUtils(Interface): 40 52 """A collection of methods which are subject to customization. … … 324 336 required = True, 325 337 ), 338 constraint=unique_currency, 326 339 required = False, 327 340 readonly = False, … … 379 392 product_options = schema.List( 380 393 value_type = ProductOptionField(), 394 constraint=unique_currency, 381 395 required = False, 382 396 readonly = False, -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12750 r12768 49 49 from waeup.ikoba.browser.tests.test_pdf import samples_dir 50 50 from waeup.ikoba.products.productoptions import ProductOption 51 from waeup.ikoba.customers.interfaces import CurrencyMismatch 51 52 52 53 PH_LEN = 15911 # Length of placeholder file … … 1297 1298 contract.product_options = [prodoption, ] 1298 1299 1300 def test_multiple_currencies(self): 1301 prodoption1 = ProductOption() 1302 prodoption1.title = u'Any product option in Euros' 1303 prodoption1.fee = Decimal('88.8') 1304 prodoption1.currency = 'EUR' 1305 prodoption2 = ProductOption() 1306 prodoption2.title = u'Any product option in Dollars' 1307 prodoption2.fee = Decimal('99.9') 1308 prodoption2.currency = 'USD' 1309 self.assertRaises(CurrencyMismatch, 1310 setattr, self.contract, 1311 'product_options', 1312 [prodoption1, prodoption2] 1313 ) 1314 1299 1315 def prepare_payment_select(self): 1300 1316 IWorkflowState(self.customer).setState('approved')
Note: See TracChangeset for help on using the changeset viewer.