- Timestamp:
- 2 Jan 2015, 07:50:34 (10 years ago)
- 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 1245 1245 right_customer_state = self.context.customer.state in getUtility( 1246 1246 ICustomersUtils).CONMANAGE_CUSTOMER_STATES 1247 if isCustomer(self.request.principal) and notright_customer_state:1248 return False1249 return True1247 if right_customer_state: 1248 return True 1249 return False 1250 1250 1251 1251 def update(self): … … 1296 1296 1297 1297 def update(self): 1298 if not self.context.is_editable and self.context.product_options == []:1298 if self.context.product_object is not None: 1299 1299 emit_lock_message(self) 1300 1300 return … … 1304 1304 def save(self, **data): 1305 1305 msave(self, **data) 1306 self.context.tc_dict = self.context.product_object.tc_dict 1306 1307 isCustomer = getattr( 1307 1308 self.request.principal, 'user_type', None) == 'customer' … … 1331 1332 return form_fields 1332 1333 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 1333 1343 1334 1344 class ContractManageFormPage(IkobaEditFormPage): … … 1351 1361 def form_fields(self): 1352 1362 return grok.AutoFields(self.context.form_fields_interface).omit( 1353 'contract_id' )1363 'contract_id', 'product_object') 1354 1364 1355 1365 @property -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt
r12345 r12363 28 28 </tbody> 29 29 </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 79 79 self.contract_id = unicode(source.get_hex_uuid()) 80 80 self.last_product_id = None 81 self.tc_dict = {} 81 82 return 82 83 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12337 r12363 295 295 user_id = Attribute('Id of a user, actually the id of the customer') 296 296 title = Attribute('Title generated by the associated product') 297 tc_dict = Attribute('Multilingual "Terms and Conditions" dict') 297 298 298 299 contract_id = schema.TextLine( -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r12358 r12363 150 150 contract.document_object = self.document 151 151 contract.product_options = self.product.options 152 contract.tc_dict = {'en': u'Hello world'} 152 153 customer['contracts'].addContract(contract) 153 154 self.contract = contract -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12358 r12363 107 107 self.product.contract_category = u'sample' 108 108 self.product.valid_from = date(2015, 12, 4) 109 self.product.tc_dict = {'en': u'Hello world'} 109 110 prodoption = ProductOption() 110 111 prodoption.title = u'First option' … … 1179 1180 conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0] 1180 1181 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) 1185 1190 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) 1188 1194 self.browser.getLink("View").click() 1189 1195 self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid) 1196 self.assertEqual(contract.tc_dict, {'en': u'Hello world'}) 1190 1197 1191 1198 # Transitions can be performed -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r12342 r12363 257 257 'class_name,contract_category,contract_id,document_object,' 258 258 'history,last_product_id,' 259 'product_object,product_options,state,t itle,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' 262 262 ) 263 263 return … … 273 273 'class_name,contract_category,contract_id,document_object,' 274 274 'history,last_product_id,' 275 'product_object,product_options,state,t itle,user_id\r\n'275 'product_object,product_options,state,tc_dict,title,user_id\r\n' 276 276 277 277 'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - ' 278 278 'Contract created by system\'],,' 279 279 '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', 281 281 result 282 282 ) … … 293 293 'class_name,contract_category,contract_id,document_object,' 294 294 'history,last_product_id,' 295 'product_object,product_options,state,t itle,user_id\r\n'295 'product_object,product_options,state,tc_dict,title,user_id\r\n' 296 296 297 297 'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - ' 298 298 'Contract created by system\'],,' 299 299 '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', 301 301 result 302 302 ) … … 313 313 'class_name,contract_category,contract_id,document_object,' 314 314 'history,last_product_id,' 315 'product_object,product_options,state,t itle,user_id\r\n'315 'product_object,product_options,state,tc_dict,title,user_id\r\n' 316 316 317 317 'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - ' 318 318 'Contract created by system\'],,' 319 319 '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.