- Timestamp:
- 2 Dec 2014, 14:38:31 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12112 r12119 47 47 from waeup.ikoba.browser.interfaces import ICaptchaManager 48 48 from waeup.ikoba.mandates.mandate import PasswordMandate 49 from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget 49 50 from waeup.ikoba.utils.helpers import get_current_principal, to_timezone, now 50 51 from waeup.ikoba.customers.interfaces import ( … … 68 69 if changed_fields: 69 70 changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) 70 if 'product ' in changed_fields and data['product'] is not None:71 view.context.last_product_id = data['product '].product_id71 if 'product_object' in changed_fields and data['product_object'] is not None: 72 view.context.last_product_id = data['product_object'].product_id 72 73 notify(grok.ObjectModifiedEvent(view.context)) 73 74 fields_string = ' + '.join(changed_fields) … … 1155 1156 @property 1156 1157 def form_fields(self): 1157 returngrok.AutoFields(self.context.form_fields_interface).omit(1158 form_fields = grok.AutoFields(self.context.form_fields_interface).omit( 1158 1159 'last_transition_date') 1160 for field in form_fields: 1161 if field.__name__.endswith('_object'): 1162 form_fields[field.__name__].custom_widget = HREFDisplayWidget 1163 return form_fields 1159 1164 1160 1165 @property -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12103 r12119 288 288 ) 289 289 290 product = schema.Choice(290 product_object = schema.Choice( 291 291 title = _(u'Product'), 292 292 source = ConCatProductSource(), … … 300 300 """ 301 301 302 product = schema.Choice(302 product_object = schema.Choice( 303 303 title = _(u'Product'), 304 304 source = ConCatProductSource(), … … 312 312 """ 313 313 314 document = schema.Choice(314 document_object = schema.Choice( 315 315 title = _(u'Document'), 316 316 source = CustomerDocumentSource(), … … 324 324 """ 325 325 326 product = schema.Choice(326 product_object = schema.Choice( 327 327 title = _(u'Product'), 328 328 source = ConCatProductSource(), … … 330 330 ) 331 331 332 document = schema.Choice(332 document_object = schema.Choice( 333 333 title = _(u'Document'), 334 334 source = CustomerDocumentSource(), -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12112 r12119 1074 1074 self.browser.getLink("c102").click() 1075 1075 self.browser.getLink("Manage").click() 1076 self.browser.getControl(name="form.product ").value = ['SAM']1076 self.browser.getControl(name="form.product_object").value = ['SAM'] 1077 1077 self.browser.getControl(name="form.title").value = 'My second contract' 1078 1078 self.browser.getControl("Save").click() … … 1134 1134 contract = self.customer['contracts']['c102'] 1135 1135 # Contract can be edited ... 1136 self.browser.getLink("c102").click()1137 1136 self.browser.open(self.contracts_path + '/c102/edit') 1138 1137 #self.browser.getLink("Edit").click() … … 1148 1147 # So far last_product_id is None. 1149 1148 self.assertTrue(self.customer['contracts']['c102'].last_product_id is None) 1150 self.browser.getControl(name="form.product ").value = ['SAM']1149 self.browser.getControl(name="form.product_object").value = ['SAM'] 1151 1150 self.browser.getControl("Save").click() 1152 1151 # Document is a required field on edit form page. … … 1157 1156 IWorkflowState(self.document).setState(SUBMITTED) 1158 1157 self.browser.open(self.contracts_path + '/c102/edit') 1159 self.browser.getControl(name="form.product ").value = ['SAM']1160 self.browser.getControl(name="form.document ").value = ['d101']1158 self.browser.getControl(name="form.product_object").value = ['SAM'] 1159 self.browser.getControl(name="form.document_object").value = ['d101'] 1161 1160 self.browser.getControl(name="form.title").value = 'My second contract' 1162 1161 self.browser.getControl("Save").click() … … 1165 1164 self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM') 1166 1165 self.assertEqual(contract.title, 'My second contract') 1167 self.assertEqual(contract.product , self.product)1168 self.assertEqual(contract.document , self.document)1166 self.assertEqual(contract.product_object, self.product) 1167 self.assertEqual(contract.document_object, self.document) 1169 1168 # Saving the form again does not unset last_product_id 1170 1169 self.browser.getControl(name="form.title").value = 'My third contract' … … 1174 1173 self.browser.getLink("View").click() 1175 1174 self.assertEqual(self.browser.url, self.contracts_path + '/c102/index') 1175 # An href attribute is referring to the document and product objects 1176 self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -' 1177 in self.browser.contents) 1178 self.assertTrue( 1179 '<a href="http://localhost/app/customers/K1000000/documents/d101">d101 -' 1180 in self.browser.contents) 1176 1181 # Customer can submit the form. The form is also saved. 1177 1182 self.browser.getLink("Edit").click()
Note: See TracChangeset for help on using the changeset viewer.