Ignore:
Timestamp:
20 Jan 2015, 17:31:11 (10 years ago)
Author:
Henrik Bettermann
Message:

Add interface and page for editing official use data. Adjust exporter.

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

    r12490 r12500  
    13821382
    13831383
     1384class ContractOfficialUsePage(IkobaEditFormPage):
     1385    """ Page to manage a official use data of contract
     1386    """
     1387    grok.context(IContract)
     1388    grok.name('official_use')
     1389    grok.require('waeup.manageCustomer')
     1390    grok.template('contracteditpage')
     1391    pnav = 4
     1392    deletion_warning = _('Are you sure?')
     1393
     1394    @property
     1395    def form_fields(self):
     1396        return grok.AutoFields(self.context.ou_form_fields_interface)
     1397
     1398    @property
     1399    def label(self):
     1400        return self.context.title
     1401
     1402    @action(_('Save'), style='primary')
     1403    def save(self, **data):
     1404        msave(self, **data)
     1405        return
     1406
     1407
    13841408class ContractEditFormPage(ContractManageFormPage):
    13851409    """ Page to edit a contract by customer only
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py

    r12486 r12500  
    3131from waeup.ikoba.customers.interfaces import (
    3232    IContractsContainer, ICustomerNavigation,
    33     IContract, IContractProcess, IContractSelectProduct, ICustomersUtils,
    34     ISampleContract, ISampleContractProcess, ISampleContractEdit)
     33    IContract, IContractSelectProduct, ICustomersUtils,
     34    ISampleContract, ISampleContractProcess, ISampleContractEdit,
     35    ISampleContractOfficialUse)
    3536from waeup.ikoba.customers.utils import generate_contract_id
    3637from waeup.ikoba.utils.helpers import attrs_to_fields
     
    6465
    6566    grok.baseclass()
    66 
    67     check_docs_interface = None
    68 
    69     contract_category = None
    70 
    71     form_fields_interface = None
    72 
    73     edit_form_fields_interface = None
    7467
    7568    def __init__(self):
     
    186179    edit_form_fields_interface = ISampleContractEdit
    187180
     181    ou_form_fields_interface = ISampleContractOfficialUse
     182
    188183    check_docs_interface = ISampleContract
    189184
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py

    r12483 r12500  
    2828from waeup.ikoba.customers.interfaces import (
    2929    ICustomer, ICSVCustomerExporter,
    30     ICustomerSampleDocument, ISampleContract)
     30    ICustomerSampleDocument, ISampleContractProcess)
    3131from waeup.ikoba.utils.batching import ExporterBase
    3232from waeup.ikoba.utils.helpers import iface_names, to_timezone
     
    242242    """
    243243    grok.name('samplecontracts')
    244     iface = ISampleContract
     244    iface = ISampleContractProcess
    245245    class_name = 'SampleContract'
    246246    title = _(u'Customer Sample Contracts')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12487 r12500  
    321321
    322322
    323 class IContractProcess(IContract):
     323class IContractSelectProduct(Interface):
     324    """Interface for for the ContractSelectProductPage.
     325
     326    """
     327
     328    product_object = schema.Choice(
     329        title = _(u'Product'),
     330        source = ConCatProductSource(),
     331        required = True,
     332        )
     333
     334
     335class ISampleContract(IContract):
     336    """A customer contract sample with document attached.
     337
     338    """
     339
     340    document_object = schema.Choice(
     341        title = _(u'Document'),
     342        source = CustomerDocumentSource(),
     343        required = False,
     344        )
     345
     346
     347class ISampleContractOfficialUse(IIkobaObject):
     348    """Interface for official use only.
     349    """
     350
     351    comment = schema.Text(
     352        title = _(u'Comment'),
     353        required = False,
     354        )
     355
     356
     357class ISampleContractProcess(ISampleContract, ISampleContractOfficialUse):
    324358    """Interface for processing contract data.
    325359    """
     
    334368
    335369
    336 class IContractSelectProduct(Interface):
    337     """Interface for for the ContractSelectProductPage.
    338 
    339     """
    340 
    341     product_object = schema.Choice(
    342         title = _(u'Product'),
    343         source = ConCatProductSource(),
    344         required = True,
    345         )
    346 
    347 
    348 class ISampleContract(IContract):
    349     """A customer contract sample with document attached.
     370class ISampleContractEdit(ISampleContract):
     371    """Interface for editing sample contract data by customers.
    350372
    351373    """
     
    354376        title = _(u'Document'),
    355377        source = CustomerDocumentSource(),
    356         required = False,
    357         )
    358 
    359 
    360 class ISampleContractProcess(ISampleContract):
    361     """Interface for processing contract data.
    362     """
    363 
    364     product_options = schema.List(
    365         title = _(u'Options/Fees'),
    366         value_type = ProductOptionField(),
    367         required = False,
    368         readonly = False,
    369         default = [],
    370         )
    371 
    372 
    373 class ISampleContractEdit(ISampleContract):
    374     """Interface for editing sample contract data by customers.
    375 
    376     """
    377 
    378     document_object = schema.Choice(
    379         title = _(u'Document'),
    380         source = CustomerDocumentSource(),
    381         required = True,
    382         )
     378        required = True,
     379        )
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12462 r12500  
    12151215        self.assertEqual(contract.state, 'approved')
    12161216
     1217        # Even in state approved the official use data can be edited
     1218        self.browser.open(self.contracts_path + '/%s/index' % conid)
     1219        self.browser.getLink("Manage official data").click()
     1220        self.browser.getControl(name="form.comment").value = u'Nice place'
     1221        self.browser.getControl("Save").click()
     1222        self.assertEqual(contract.comment, 'Nice place')
     1223        self.assertTrue('Form has been saved.' in self.browser.contents)
     1224
    12171225        # Contracts can be removed
    12181226        self.browser.getLink("Contracts").click()
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12363 r12500  
    255255        self.assertEqual(
    256256            result,
    257             'class_name,contract_category,contract_id,document_object,'
     257            'class_name,comment,contract_category,contract_id,document_object,'
    258258            'history,last_product_id,'
    259259            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    260260
    261             'SampleContract,sample,CON1,,[],,,[],,{},,\r\n'
     261            'SampleContract,,sample,CON1,,[],,,[],,{},,\r\n'
    262262            )
    263263        return
     
    271271        result = open(self.outfile, 'rb').read()
    272272        self.assertMatches(
    273             'class_name,contract_category,contract_id,document_object,'
     273            'class_name,comment,contract_category,contract_id,document_object,'
    274274            'history,last_product_id,'
    275275            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    276276
    277             'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     277            '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\')]",'
     
    291291        result = open(self.outfile, 'rb').read()
    292292        self.assertMatches(
    293             'class_name,contract_category,contract_id,document_object,'
     293            'class_name,comment,contract_category,contract_id,document_object,'
    294294            'history,last_product_id,'
    295295            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    296296
    297             'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     297            '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\')]",'
     
    311311        result = open(self.outfile, 'rb').read()
    312312        self.assertMatches(
    313             'class_name,contract_category,contract_id,document_object,'
     313            'class_name,comment,contract_category,contract_id,document_object,'
    314314            'history,last_product_id,'
    315315            'product_object,product_options,state,tc_dict,title,user_id\r\n'
    316316
    317             'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     317            '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\')]",'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12351 r12500  
    3535    DocumentsManageFormPage, DocumentDisplayFormPage, DocumentManageFormPage,
    3636    ContractsFormPage, ContractDisplayFormPage,
    37     ContractManageFormPage)
     37    ContractManageFormPage,
     38    ContractOfficialUsePage)
    3839
    3940grok.context(IIkobaObject)  # Make IIkobaObject the default context
     
    405406
    406407
     408class ContractOUActionButton(ManageActionButton):
     409    grok.order(2)
     410    grok.context(IContract)
     411    grok.view(ContractDisplayFormPage)
     412    grok.require('waeup.manageCustomer')
     413    text = _('Manage official data')
     414    target = 'official_use'
     415
     416
    407417class ContractEditActionButton(ManageActionButton):
    408418    grok.order(1)
     
    421431
    422432class ContractTrigTransActionButton(ManageActionButton):
    423     grok.order(2)
     433    grok.order(3)
    424434    grok.context(IContract)
    425435    grok.view(ContractDisplayFormPage)
     
    440450
    441451
     452class ContractViewActionButton2(ContractViewActionButton):
     453    grok.view(ContractOfficialUsePage)
     454
     455
    442456class PDFContractSlipActionButton(ManageActionButton):
    443     grok.order(3)
     457    grok.order(4)
    444458    grok.context(IContract)
    445459    grok.view(ContractDisplayFormPage)
Note: See TracChangeset for help on using the changeset viewer.