Changeset 12103 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 1 Dec 2014, 09:59:14 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12099 r12103 51 51 ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils, 52 52 ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate, 53 ICustomerPDFDocument, IContractsContainer, IContract, IContractEdit 53 ICustomerPDFDocument, IContractsContainer, IContract, IContractEdit, 54 ISampleContract, 54 55 ) 55 56 from waeup.ikoba.customers.catalog import search … … 1150 1151 grok.require('waeup.viewCustomer') 1151 1152 grok.template('contractpage') 1152 form_fields = grok.AutoFields(IContract).omit('last_transition_date') 1153 pnav = 4 1153 pnav = 4 1154 1155 @property 1156 def form_fields(self): 1157 return grok.AutoFields(self.context.form_fields_interface).omit( 1158 'last_transition_date') 1154 1159 1155 1160 @property … … 1165 1170 grok.require('waeup.manageCustomer') 1166 1171 grok.template('contracteditpage') 1167 form_fields = grok.AutoFields(IContract).omit('last_transition_date')1168 1172 pnav = 4 1169 1173 deletion_warning = _('Are you sure?') 1174 1175 @property 1176 def form_fields(self): 1177 return grok.AutoFields(self.context.form_fields_interface).omit( 1178 'last_transition_date') 1170 1179 1171 1180 @property … … 1184 1193 grok.name('edit') 1185 1194 grok.require('waeup.handleCustomer') 1186 form_fields = grok.AutoFields(IContractEdit).omit('last_transition_date') 1195 1196 @property 1197 def form_fields(self): 1198 return grok.AutoFields(self.context.edit_form_fields_interface).omit( 1199 'last_transition_date') 1187 1200 1188 1201 def update(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py
r12099 r12103 30 30 IContractsContainer, ICustomerNavigation, 31 31 IContract, IContractEdit, ICustomersUtils, 32 )32 ISampleContract, ISampleContractEdit) 33 33 from waeup.ikoba.customers.utils import generate_contract_id 34 34 from waeup.ikoba.utils.helpers import attrs_to_fields … … 64 64 65 65 contract_category = None 66 67 form_fields_interface = None 68 69 edit_form_fields_interface = None 66 70 67 71 def __init__(self): … … 142 146 """ 143 147 148 grok.implements(ISampleContract, ISampleContractEdit, ICustomerNavigation) 149 144 150 contract_category = 'sample' 151 152 form_fields_interface = ISampleContract 153 154 edit_form_fields_interface = ISampleContractEdit 145 155 146 156 SampleContract = attrs_to_fields(SampleContract) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12098 r12103 29 29 30 30 from waeup.ikoba.customers.vocabularies import ( 31 contextual_reg_num_source, GenderSource, nats_vocab, ConCatProductSource) 31 contextual_reg_num_source, GenderSource, nats_vocab, 32 ConCatProductSource, CustomerDocumentSource) 32 33 33 34 … … 293 294 ) 294 295 296 295 297 class IContractEdit(IContract): 296 298 """Interface for editing contract data by customers. … … 303 305 required = True, 304 306 ) 307 308 309 class ISampleContract(IContract): 310 """A customer contract sample with document attached. 311 312 """ 313 314 document = schema.Choice( 315 title = _(u'Document'), 316 source = CustomerDocumentSource(), 317 required = False, 318 ) 319 320 321 class ISampleContractEdit(ISampleContract): 322 """Interface for editing sample contract data by customers. 323 324 """ 325 326 product = schema.Choice( 327 title = _(u'Product'), 328 source = ConCatProductSource(), 329 required = True, 330 ) 331 332 document = schema.Choice( 333 title = _(u'Document'), 334 source = CustomerDocumentSource(), 335 required = True, 336 ) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12098 r12103 40 40 from waeup.ikoba.customers.interfaces import ICustomersUtils 41 41 from waeup.ikoba.customers.customer import Customer 42 from waeup.ikoba.interfaces import IUserAccount, IJobManager, APPROVED 42 from waeup.ikoba.interfaces import ( 43 IUserAccount, IJobManager, APPROVED, SUBMITTED) 43 44 from waeup.ikoba.authentication import LocalRoleSetEvent 44 45 from waeup.ikoba.tests.test_async import FunctionalAsyncTestCase … … 111 112 self.customer_id = customer.customer_id 112 113 self.customer = self.app['customers'][self.customer_id] 113 document = createObject('waeup.CustomerSampleDocument')114 document.title = u'My first document'115 self.customer['documents'].addDocument( document)116 contract = createObject('waeup.SampleContract')117 contract.title = u'My first contract'118 self.customer['contracts'].addContract( contract)114 self.document = createObject('waeup.CustomerSampleDocument') 115 self.document.title = u'My first document' 116 self.customer['documents'].addDocument(self.document) 117 self.contract = createObject('waeup.SampleContract') 118 self.contract.title = u'My first contract' 119 self.customer['contracts'].addContract(self.contract) 119 120 120 121 # Set password … … 1074 1075 self.browser.getLink("Manage").click() 1075 1076 self.browser.getControl(name="form.product").value = ['SAM'] 1076 self.browser.getControl(name="form.title").value = 'My second app'1077 self.browser.getControl(name="form.title").value = 'My second contract' 1077 1078 self.browser.getControl("Save").click() 1078 1079 self.assertTrue('Form has been saved.' in self.browser.contents) … … 1140 1141 IWorkflowState(self.customer).setState(APPROVED) 1141 1142 self.browser.open(self.contracts_path + '/c102/edit') 1142 self.browser.getControl(name="form.title").value = 'My second app'1143 self.browser.getControl(name="form.title").value = 'My second contract' 1143 1144 # SAM is in the correct contract_category ... 1144 1145 self.assertTrue('<option value="SAM">' in self.browser.contents) … … 1149 1150 self.browser.getControl(name="form.product").value = ['SAM'] 1150 1151 self.browser.getControl("Save").click() 1151 # After saving the form, last_product_id is set. 1152 # Document is a required field on edit form page. 1153 self.assertTrue('Document: <span class="error">Required input is missing.</span>' 1154 in self.browser.contents) 1155 # But our document can't be selected because it's not submitted 1156 self.assertFalse('My first document' in self.browser.contents) 1157 IWorkflowState(self.document).setState(SUBMITTED) 1158 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'] 1161 self.browser.getControl(name="form.title").value = 'My second contract' 1162 self.browser.getControl("Save").click() 1163 # After saving the form, last_product_id and other attributes are set 1164 self.assertTrue('Form has been saved.' in self.browser.contents) 1152 1165 self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM') 1153 self.assertTrue('Form has been saved.' in self.browser.contents) 1166 self.assertEqual(contract.title, 'My second contract') 1167 self.assertEqual(contract.product, self.product) 1168 self.assertEqual(contract.document, self.document) 1154 1169 # Saving the form again does not unset last_product_id 1155 self. assertEqual(contract.title, 'My second app')1170 self.browser.getControl(name="form.title").value = 'My third contract' 1156 1171 self.browser.getControl("Save").click() 1157 1172 self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM') … … 1161 1176 # Customer can submit the form. The form is also saved. 1162 1177 self.browser.getLink("Edit").click() 1163 self.browser.getControl(name="form.title").value = 'My third app'1178 self.browser.getControl(name="form.title").value = 'My fourth contract' 1164 1179 self.browser.getControl("Apply now").click() 1165 self.assertEqual(contract.title, 'My third app')1180 self.assertEqual(contract.title, 'My fourth contract') 1166 1181 self.assertEqual(contract.state, 'submitted') 1167 1182 self.assertTrue('Contract State: submitted for approval' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.