Ignore:
Timestamp:
19 Oct 2016, 09:48:38 (8 years ago)
Author:
Henrik Bettermann
Message:

Contracts must not be added if there are no active products for this category.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
2 edited

Legend:

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

    r14208 r14215  
    12901290        # classes depending on the contype parameter given in form.
    12911291        contract = createObject('waeup.%s' % contype)
     1292        # Check whether there are active products for this contract.
     1293        concat = getattr(contract, 'contract_category', None)
     1294        products = grok.getSite()['products'].values()
     1295        active_products = [
     1296            value for value in products
     1297            if value.contract_category == concat and value.active
     1298            ]
     1299        if not len(active_products):
     1300            self.flash(_('No active products in this category.'), type='warning')
     1301            self.redirect(self.url(self.context))
     1302            return
    12921303        self.context.addContract(contract)
    12931304        contype = getUtility(ICustomersUtils).SELECTABLE_CONTYPES_DICT[contype]
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r14208 r14215  
    13501350        self.browser.getControl("Add contract").click()
    13511351        self.browser.getControl(name="contype").value = ['SampleContract']
     1352        # No active product
     1353        self.product.valid_to = date(2014, 12, 4)
     1354        self.browser.getControl("Add contract").click()
     1355        self.assertTrue('No active products in this category.'
     1356            in self.browser.contents)
     1357        self.product.valid_to = date(2050, 12, 4)
     1358        self.browser.getControl("Add contract").click()
     1359        self.browser.getControl(name="contype").value = ['SampleContract']
    13521360        self.browser.getControl("Add contract").click()
    13531361        self.assertTrue('Sample Contract added.' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.