Ignore:
Timestamp:
29 Dec 2014, 16:12:24 (10 years ago)
Author:
Henrik Bettermann
Message:

Define contract title in product. Customers must not be able to edit contract titles.

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

Legend:

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

    r12333 r12336  
    110110
    111111    @property
     112    def title(self):
     113        return getattr(
     114            getattr(self, 'product_object', None),
     115            'contract_autotitle', None)
     116
     117    @property
    112118    def customer(self):
    113119        try:
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12333 r12336  
    294294    translated_class_name = Attribute('Translatable class name')
    295295    user_id = Attribute('Id of a user, actually the id of the customer')
     296    title = Attribute('Title generated by the associated product')
    296297
    297298    contract_id = schema.TextLine(
     
    299300        required = False,
    300301        constraint=validate_uuid,
    301         )
    302 
    303     title = schema.TextLine(
    304         title = _(u'Contract Title'),
    305         required = True,
    306302        )
    307303
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_contract_data.csv

    r12333 r12336  
    1 class_name,contract_id,reg_number,title,product_object,document_object,product_options
    2 SampleContract,c3,1,My first contract,SAM,DOC1,"[('Base Fee', '800.6', 'usd')]"
    3 SampleContract,c4,2,My second contract,SAM,DOC1,[]
    4 SampleContract,c5,3,My third contract,SAM,DOC1,[]
    5 SampleContract,,1,My 4th contract,SAM,DOC1,[]
    6 SampleContract,c5,2,My stolen contract,SAM,DOC1,[]
    7 SampleContract,c6,3,My 5th contract,SAM,NONEXISTENT,[]
    8 SampleContract,c7,3,My sixt contract,NONEXISTENT,DOC1,[]
     1class_name,contract_id,reg_number,product_object,document_object,product_options
     2SampleContract,c3,1,SAM,DOC1,"[('Base Fee', '800.6', 'usd')]"
     3SampleContract,c4,2,SAM,DOC1,[]
     4SampleContract,c5,3,SAM,DOC1,[]
     5SampleContract,,1,SAM,DOC1,[]
     6SampleContract,c5,2,SAM,DOC1,[]
     7SampleContract,c6,3,SAM,NONEXISTENT,[]
     8SampleContract,c7,3,NONEXISTENT,DOC1,[]
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12333 r12336  
    9999        self.product = createObject('waeup.Product')
    100100        self.product.product_id = u'SAM'
    101         self.product.title = u'Our Samle Product'
     101        self.product.title = u'Our Sample Product'
    102102        self.product.contract_category = u'sample'
    103103        option = ProductOption()
     
    145145        # Add contract
    146146        contract = createObject('waeup.SampleContract')
    147         contract.title = u'My Contract'
    148147        contract.contract_id = u'CON1'
    149148        contract.product_object = self.product
     
    490489        fail_file = open(fail_file).read()
    491490        self.assertEqual(fail_file,
    492             'reg_number,contract_id,title,class_name,product_object,document_object,product_options,--ERRORS--\r\n'
    493             '2,c5,My stolen contract,SampleContract,SAM,DOC1,[],This object already exists. Skipping.\r\n'
    494             '3,c6,My 5th contract,SampleContract,SAM,NONEXISTENT,[],document_object: Invalid value\r\n'
    495             '3,c7,My sixt contract,SampleContract,NONEXISTENT,DOC1,[],product_object: Invalid value\r\n'
     491            'reg_number,contract_id,class_name,product_object,document_object,product_options,--ERRORS--\r\n'
     492            '2,c5,SampleContract,SAM,DOC1,[],This object already exists. Skipping.\r\n'
     493            '3,c6,SampleContract,SAM,NONEXISTENT,[],document_object: Invalid value\r\n'
     494            '3,c7,SampleContract,NONEXISTENT,DOC1,[],product_object: Invalid value\r\n'
    496495            )
    497496        contract = self.processor.getEntry(dict(reg_number='1',
     
    514513        self.assertTrue(
    515514            'INFO - system - Customer Sample Contract Processor - sample_contract_data - '
    516             'X666666 - %s - updated: title=My 4th contract, '
    517             'product_object=SAM, document_object=DOC1' % conid
     515            'X666666 - %s - updated: product_object=SAM, document_object=DOC1, '
     516            'product_options=[]' % conid
    518517            in logcontent)
    519518
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12262 r12336  
    102102        self.product = createObject('waeup.Product')
    103103        self.product.product_id = u'SAM'
    104         self.product.title = u'Our Samle Product'
     104        self.product.title = u'Our Sample Product'
    105105        self.product.contract_category = u'sample'
    106106        self.app['products'].addProduct(self.product)
     
    125125        self.customer['documents'].addDocument(self.document)
    126126        self.contract = createObject('waeup.SampleContract')
    127         self.contract.title = u'My first contract'
    128127        self.contract.contract_id = u'CON1'
    129128        self.assertRaises(
     
    11631162        self.browser.getControl("Add contract").click()
    11641163        self.browser.getControl(name="contype").value = ['SampleContract']
    1165         self.browser.getControl(name="form.title").value = 'My Sample Contract'
    11661164        self.browser.getControl("Add contract").click()
    11671165        self.assertTrue('Sample Contract added.' in self.browser.contents)
     
    11731171        self.browser.getLink("Manage").click()
    11741172        self.browser.getControl(name="form.product_object").value = ['SAM']
    1175         self.browser.getControl(name="form.title").value = 'My second contract'
    11761173        self.browser.getControl("Save").click()
    11771174        self.assertTrue('Form has been saved.' in self.browser.contents)
     
    12061203            '- K1000000 - added: Sample Contract %s'
    12071204            % contract.contract_id in logcontent)
    1208         self.assertTrue(
    1209             'INFO - zope.mgr - customers.browser.ContractManageFormPage '
    1210             '- K1000000 - %s - saved: title' % conid
    1211             in logcontent)
    12121205        self.assertTrue(
    12131206            'INFO - zope.mgr - K1000000 - %s - Submitted for approval' % conid
     
    12381231        self.browser.getControl("Add contract").click()
    12391232        self.browser.getControl(name="contype").value = ['SampleContract']
    1240         self.browser.getControl(name="form.title").value = 'My Sample Contract'
    12411233        self.browser.getControl("Add contract").click()
    12421234        self.assertTrue('Sample Contract added.' in self.browser.contents)
     
    12501242        IWorkflowState(self.customer).setState(APPROVED)
    12511243        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    1252         self.browser.getControl(name="form.title").value = 'My second contract'
    12531244        # SAM is in the correct contract_category ...
    12541245        self.assertTrue('<option value="SAM">' in self.browser.contents)
     
    12681259        self.browser.getControl(name="form.product_object").value = ['SAM']
    12691260        self.browser.getControl(name="form.document_object").value = ['DOC1']
    1270         self.browser.getControl(name="form.title").value = 'My second contract'
    12711261        self.browser.getControl("Save").click()
    12721262        # After saving the form, last_product_id and other attributes are set
    12731263        self.assertTrue('Form has been saved.' in self.browser.contents)
    12741264        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
    1275         self.assertEqual(contract.title, 'My second contract')
     1265        self.assertEqual(contract.title, 'Our Sample Product')
    12761266        self.assertEqual(contract.product_object, self.product)
    12771267        self.assertEqual(contract.document_object, self.document)
    12781268        # Saving the form again does not unset last_product_id
    1279         self.browser.getControl(name="form.title").value = 'My third contract'
    12801269        self.browser.getControl("Save").click()
    12811270        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
     
    12911280        # Customer can submit the form. The form is also saved.
    12921281        self.browser.getLink("Edit").click()
    1293         self.browser.getControl(name="form.title").value = 'My fourth contract'
    1294         self.browser.getControl("Apply now").click()
    1295         self.assertEqual(contract.title, 'My fourth contract')
     1282        self.browser.getControl("Apply now").click()
    12961283        self.assertEqual(contract.state, 'submitted')
    12971284        self.assertTrue('Contract State: submitted for approval' in self.browser.contents)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py

    r12259 r12336  
    6262        product = createObject('waeup.Product')
    6363        product.product_id = u'SAM'
    64         product.title = u'Our Samle Product'
     64        product.title = u'Our Sample Product'
    6565        product.contract_category = u'sample'
    6666        self.app['products'].addProduct(product)
     
    6969
    7070        document = createObject('waeup.CustomerSampleDocument')
    71         document.title = u'My Samle Document'
     71        document.title = u'My Sample Document'
    7272        IWorkflowState(document).setState(VERIFIED)
    7373        self.customer['documents'].addDocument(document)
     
    7676
    7777        contract = createObject('waeup.SampleContract')
    78         contract.title = u'My Samle Contract'
    7978        contract.contract_id = u'CON1'
    8079        contract.product_object = product
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12330 r12336  
    278278            'Contract created by system\'],,'
    279279            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'usd\')]",'
    280             'created,My Contract,A111111\r\n',
     280            'created,Our Sample Product,A111111\r\n',
    281281            result
    282282            )
     
    298298            'Contract created by system\'],,'
    299299            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'usd\')]",'
    300             'created,My Contract,A111111\r\n',
     300            'created,Our Sample Product,A111111\r\n',
    301301            result
    302302            )
     
    318318            'Contract created by system\'],,'
    319319            'SAM,"[(u\'Base Fee\', u\'800.6\', u\'usd\')]",'
    320             'created,My Contract,A111111\r\n',
    321             result
    322             )
    323         return
    324 
     320            'created,Our Sample Product,A111111\r\n',
     321            result
     322            )
     323        return
     324
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_interfaces.py

    r12256 r12336  
    6868
    6969        contract = createObject('waeup.SampleContract')
    70         contract.title = u'My Samle Contract'
    7170        contract.product = product
    7271        contract.last_product_id = product.product_id
     
    7675
    7776        document = createObject('waeup.CustomerSampleDocument')
    78         document.title = u'My Samle Document'
     77        document.title = u'My Sample Document'
    7978        document.document_id = u'DOC1'
    8079        self.customer['documents'].addDocument(document)
     
    108107        source = CustomerDocumentSource()
    109108        result = source.factory.getTitle(object(), self.document)
    110         self.assertEqual(result, u'DOC1 - My Samle Document')
     109        self.assertEqual(result, u'DOC1 - My Sample Document')
    111110
Note: See TracChangeset for help on using the changeset viewer.