Ignore:
Timestamp:
2 Jan 2015, 07:50:34 (10 years ago)
Author:
Henrik Bettermann
Message:

Save 'terms and conditions' when adding a contract.

Prevent changing product_object after adding contract.

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

Legend:

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

    r12356 r12363  
    12451245        right_customer_state = self.context.customer.state in getUtility(
    12461246            ICustomersUtils).CONMANAGE_CUSTOMER_STATES
    1247         if isCustomer(self.request.principal) and not right_customer_state:
    1248             return False
    1249         return True
     1247        if right_customer_state:
     1248            return True
     1249        return False
    12501250
    12511251    def update(self):
     
    12961296
    12971297    def update(self):
    1298         if not self.context.is_editable and self.context.product_options == []:
     1298        if self.context.product_object is not None:
    12991299            emit_lock_message(self)
    13001300            return
     
    13041304    def save(self, **data):
    13051305        msave(self, **data)
     1306        self.context.tc_dict = self.context.product_object.tc_dict
    13061307        isCustomer = getattr(
    13071308            self.request.principal, 'user_type', None) == 'customer'
     
    13311332        return form_fields
    13321333
     1334    @property
     1335    def terms_and_conditions(self):
     1336        lang = self.request.cookies.get('ikoba.language')
     1337        html = self.context.tc_dict.get(lang,'')
     1338        if html =='':
     1339            portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     1340            html = self.context.tc_dict.get(portal_language,'')
     1341        return html
     1342
    13331343
    13341344class ContractManageFormPage(IkobaEditFormPage):
     
    13511361    def form_fields(self):
    13521362        return grok.AutoFields(self.context.form_fields_interface).omit(
    1353             'contract_id')
     1363            'contract_id', 'product_object')
    13541364
    13551365    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt

    r12345 r12363  
    2828  </tbody>
    2929</table>
     30
     31<h4 i18n:domain="waeup.ikoba">
     32  <span i18n:translate="">Terms and Conditions</span>
     33</h4>
     34
     35<tal:tc content="structure view/terms_and_conditions" />
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py

    r12352 r12363  
    7979        self.contract_id = unicode(source.get_hex_uuid())
    8080        self.last_product_id = None
     81        self.tc_dict = {}
    8182        return
    8283
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12337 r12363  
    295295    user_id = Attribute('Id of a user, actually the id of the customer')
    296296    title = Attribute('Title generated by the associated product')
     297    tc_dict = Attribute('Multilingual "Terms and Conditions" dict')
    297298
    298299    contract_id = schema.TextLine(
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12358 r12363  
    150150        contract.document_object = self.document
    151151        contract.product_options = self.product.options
     152        contract.tc_dict = {'en': u'Hello world'}
    152153        customer['contracts'].addContract(contract)
    153154        self.contract = contract
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12358 r12363  
    107107        self.product.contract_category = u'sample'
    108108        self.product.valid_from = date(2015, 12, 4)
     109        self.product.tc_dict = {'en': u'Hello world'}
    109110        prodoption = ProductOption()
    110111        prodoption.title = u'First option'
     
    11791180        conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
    11801181        contract = self.customer['contracts'][conid]
    1181 
    1182         # Contract can be edited
    1183         self.browser.getLink(conid[:6]).click()
    1184         self.browser.getLink("Manage").click()
     1182        self.assertEqual(
     1183            self.browser.url, self.contracts_path + '/%s/selectproduct' % conid)
     1184        # SAM is in the correct contract_category ...
     1185        self.assertTrue('<option value="SAM">' in self.browser.contents)
     1186        # ... but NOTSAM not.
     1187        self.assertFalse('<option value="LIC">' in self.browser.contents)
     1188        # So far last_product_id is None.
     1189        self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
    11851190        self.browser.getControl(name="form.product_object").value = ['SAM']
    1186         self.browser.getControl("Save").click()
    1187         self.assertTrue('Form has been saved.' in self.browser.contents)
     1191        self.browser.getControl("Save and proceed").click()
     1192        self.assertEqual(
     1193            self.browser.url, self.contracts_path + '/%s/manage' % conid)
    11881194        self.browser.getLink("View").click()
    11891195        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
     1196        self.assertEqual(contract.tc_dict, {'en': u'Hello world'})
    11901197
    11911198        # Transitions can be performed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12342 r12363  
    257257            'class_name,contract_category,contract_id,document_object,'
    258258            'history,last_product_id,'
    259             'product_object,product_options,state,title,user_id\r\n'
    260 
    261             'SampleContract,sample,CON1,,[],,,[],,,\r\n'
     259            'product_object,product_options,state,tc_dict,title,user_id\r\n'
     260
     261            'SampleContract,sample,CON1,,[],,,[],,{},,\r\n'
    262262            )
    263263        return
     
    273273            'class_name,contract_category,contract_id,document_object,'
    274274            'history,last_product_id,'
    275             'product_object,product_options,state,title,user_id\r\n'
     275            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    276276
    277277            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    278278            'Contract created by system\'],,'
    279279            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",'
    280             'created,Our Sample Product,A111111\r\n',
     280            'created,{\'en\': u\'Hello world\'},Our Sample Product,A111111\r\n',
    281281            result
    282282            )
     
    293293            'class_name,contract_category,contract_id,document_object,'
    294294            'history,last_product_id,'
    295             'product_object,product_options,state,title,user_id\r\n'
     295            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    296296
    297297            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    298298            'Contract created by system\'],,'
    299299            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",'
    300             'created,Our Sample Product,A111111\r\n',
     300            'created,{\'en\': u\'Hello world\'},Our Sample Product,A111111\r\n',
    301301            result
    302302            )
     
    313313            'class_name,contract_category,contract_id,document_object,'
    314314            'history,last_product_id,'
    315             'product_object,product_options,state,title,user_id\r\n'
     315            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    316316
    317317            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    318318            'Contract created by system\'],,'
    319319            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",'
    320             'created,Our Sample Product,A111111\r\n',
    321             result
    322             )
    323         return
    324 
     320            'created,{\'en\': u\'Hello world\'},Our Sample Product,A111111\r\n',
     321            result
     322            )
     323        return
     324
Note: See TracChangeset for help on using the changeset viewer.