- Timestamp:
- 23 Sep 2016, 16:38:53 (8 years ago)
- Location:
- main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/batching.py
r14181 r14184 24 24 from ikobacustom.uniben.customers.interfaces import ( 25 25 IUnibenCustomer, 26 IUnibenCustomerDocument, I UnibenContract)26 IUnibenCustomerDocument, IRIAAContract) 27 27 from ikobacustom.uniben.interfaces import MessageFactory as _ 28 28 … … 37 37 38 38 39 class UnibenCustomer DocumentProcessor(CustomerDocumentProcessorBase):39 class UnibenCustomerPDFDocumentProcessor(CustomerDocumentProcessorBase): 40 40 """A batch processor for IUnibenCustomerDocument objects. 41 41 """ 42 util_name = 'unibencustomer documentprocessor'42 util_name = 'unibencustomerpdfdocumentprocessor' 43 43 grok.name(util_name) 44 name = _('Uniben Customer Document Processor')44 name = _('Uniben Customer PDF Document Processor') 45 45 iface = IUnibenCustomerDocument 46 factory_name = 'waeup.UnibenCustomer Document'46 factory_name = 'waeup.UnibenCustomerPDFDocument' 47 47 48 48 49 class UnibenContractProcessor(ContractProcessorBase):50 """A batch processor for I UnibenContract objects.49 class RIAAContractProcessor(ContractProcessorBase): 50 """A batch processor for IRIAAContract objects. 51 51 """ 52 util_name = ' unibencontractprocessor'52 util_name = 'riaacontractprocessor' 53 53 grok.name(util_name) 54 name = _(' Uniben CustomerContract Processor')55 iface = I UnibenContract56 factory_name = 'waeup. UnibenContract'54 name = _('RIAA Contract Processor') 55 iface = IRIAAContract 56 factory_name = 'waeup.RIAAContract' -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/contracts.py
r14181 r14184 28 28 from ikobacustom.uniben.interfaces import MessageFactory as _ 29 29 from ikobacustom.uniben.customers.interfaces import ( 30 I UnibenContract, IUnibenContractEdit, IUnibenContractProcess,31 I UnibenContractOfficialUse)30 IRIAAContract, IRIAAContractEdit, IRIAAContractProcess, 31 IRIAAContractOfficialUse) 32 32 33 33 34 34 class UnibenContract(ContractBase): 35 """This is a sample contract. 35 """This is a baseclass contract. 36 """ 37 38 class RIAAContract(UnibenContract): 39 """Research and Innovative Achievement Award 36 40 """ 37 41 38 42 grok.implements( 39 I UnibenContractProcess,40 I UnibenContract,41 I UnibenContractEdit,43 IRIAAContractProcess, 44 IRIAAContract, 45 IRIAAContractEdit, 42 46 ICustomerNavigation) 43 47 44 contract_category = ' sample'48 contract_category = 'riaa' 45 49 46 form_fields_interface = I UnibenContract50 form_fields_interface = IRIAAContract 47 51 48 edit_form_fields_interface = I UnibenContractEdit52 edit_form_fields_interface = IRIAAContractEdit 49 53 50 ou_form_fields_interface = I UnibenContractOfficialUse54 ou_form_fields_interface = IRIAAContractOfficialUse 51 55 52 check_docs_interface = I UnibenContract56 check_docs_interface = IRIAAContract 53 57 54 UnibenContract = attrs_to_fields(UnibenContract)58 RIAAContract = attrs_to_fields(RIAAContract) 55 59 56 60 57 61 # Contracts must be importable. So we might need a factory. 58 class UnibenContractFactory(grok.GlobalUtility):59 """A factory for contracts.62 class RIAAContractFactory(grok.GlobalUtility): 63 """A factory for RIAAContract. 60 64 """ 61 65 grok.implements(IFactory) 62 grok.name(u'waeup. UnibenContract')63 title = u"Create a new contract.",64 description = u"This factory instantiates new samplecontract instances."66 grok.name(u'waeup.RIAAContract') 67 title = u"Create a new riaa contract.", 68 description = u"This factory instantiates new riaa contract instances." 65 69 66 70 def __call__(self, *args, **kw): 67 return UnibenContract(*args, **kw)71 return RIAAContract(*args, **kw) 68 72 69 73 def getInterfaces(self): 70 return implementedBy( UnibenContract)74 return implementedBy(RIAAContract) -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/documents.py
r14181 r14184 26 26 from waeup.ikoba.customers.documents import CustomerDocumentBase 27 27 from ikobacustom.uniben.interfaces import MessageFactory as _ 28 from ikobacustom.uniben.customers.interfaces import IUnibenCustomerDocument 28 from ikobacustom.uniben.customers.interfaces import ( 29 IUnibenCustomerDocument, IUnibenCustomerPDFDocument) 29 30 30 31 … … 40 41 # only one file per Document object. Thus the following 41 42 # tuple should contain only a single filename string. 42 filenames = ('s ample',)43 filenames = ('scan',) 43 44 44 45 form_fields_interface = IUnibenCustomerDocument … … 61 62 def getInterfaces(self): 62 63 return implementedBy(UnibenCustomerDocument) 64 65 class UnibenCustomerPDFDocument(CustomerDocumentBase): 66 """This is a sample customer document. 67 """ 68 69 grok.implements(IUnibenCustomerPDFDocument, ICustomerNavigation) 70 grok.provides(IUnibenCustomerPDFDocument) 71 72 filenames = ('scan.pdf',) 73 74 form_fields_interface = IUnibenCustomerPDFDocument 75 76 UnibenCustomerPDFDocument = attrs_to_fields(UnibenCustomerPDFDocument) 77 78 79 class UnibenCustomerPDFDocumentFactory(grok.GlobalUtility): 80 """A factory for customer documents. 81 """ 82 grok.implements(IFactory) 83 grok.name(u'waeup.UnibenCustomerPDFDocument') 84 title = u"Create a new document.", 85 description = u"This factory instantiates new document instances." 86 87 def __call__(self, *args, **kw): 88 return UnibenCustomerPDFDocument(*args, **kw) 89 90 def getInterfaces(self): 91 return implementedBy(UnibenCustomerPDFDocument) -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/export.py
r14181 r14184 22 22 CustomerExporter, CustomerDocumentExporterBase, ContractExporterBase) 23 23 from ikobacustom.uniben.customers.interfaces import ( 24 IUnibenCustomer, IUnibenCustomerDocument, IUnibenContractProcess) 24 IUnibenCustomer, IUnibenCustomerDocument, IRIAAContractProcess, 25 IUnibenCustomerPDFDocument) 25 26 from ikobacustom.uniben.interfaces import MessageFactory as _ 26 27 … … 32 33 33 34 34 class UnibenCustomer DocumentExporter(CustomerDocumentExporterBase):35 class UnibenCustomerPDFDocumentExporter(CustomerDocumentExporterBase): 35 36 """Exporter for documents. 36 37 """ 37 grok.name('unibencustomer documents')38 iface = IUnibenCustomer Document39 title = _(u'Uniben Customer Documents')40 class_name = 'UnibenCustomer Document'38 grok.name('unibencustomerpdfdocuments') 39 iface = IUnibenCustomerPDFDocument 40 title = _(u'Uniben Customer PDF Documents') 41 class_name = 'UnibenCustomerPDFDocument' 41 42 42 43 43 class UnibenContractExporter(ContractExporterBase):44 class RIAAContractExporter(ContractExporterBase): 44 45 """Exporter for Contract instances. 45 46 """ 46 grok.name(' unibencontracts')47 iface = I UnibenContractProcess48 title = _(u' UnibenCustomer Contracts')49 class_name = ' UnibenContract'47 grok.name('riaacontracts') 48 iface = IRIAAContractProcess 49 title = _(u'RIAA Customer Contracts') 50 class_name = 'RIAAContract' -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/fileviewlets.py
r14181 r14184 23 23 FileDisplay, FileUpload, Image) 24 24 25 from ikobacustom.uniben.customers.documents import UnibenCustomerDocument 25 from ikobacustom.uniben.customers.documents import ( 26 UnibenCustomerDocument, UnibenCustomerPDFDocument) 26 27 27 28 from waeup.ikoba.customers.browser import ( … … 83 84 grok.view(PDFDocumentSlip) 84 85 86 class PDFScanManageUpload(FileUpload): 87 """Scan upload viewlet for officers. 88 """ 89 grok.view(DocumentManageFormPage) 90 grok.context(UnibenCustomerPDFDocument) 91 grok.require('waeup.manageCustomer') 92 label = _(u'PDF File') 93 title = _(u'PDF File') 94 mus = 1024 * 1000 95 download_name = u'scan.pdf' 96 tab_redirect = '#tab2' 97 98 @property 99 def download_filename(self): 100 return u"%s.pdf" % self.context.document_id[:9] 101 102 103 class PDFScanEditUpload(PDFScanManageUpload): 104 """Scan upload viewlet for customer. 105 """ 106 grok.view(DocumentEditFormPage) 107 grok.require('waeup.handleCustomer') 108 109 110 class PDFScanDisplay(FileDisplay): 111 """Scan display viewlet. 112 """ 113 grok.order(1) 114 grok.context(UnibenCustomerPDFDocument) 115 grok.require('waeup.viewCustomer') 116 grok.view(DocumentDisplayFormPage) 117 label = _(u'PDF Scan') 118 title = _(u'PDF Scan') 119 download_name = u'scan.pdf' 120 121 @property 122 def download_filename(self): 123 return u"%s.pdf" % self.context.document_id[:9] 124 125 126 class PDFScanImage(Image): 127 """Scan document. 128 """ 129 grok.name('scan.pdf') 130 grok.context(UnibenCustomerPDFDocument) 131 grok.require('waeup.viewCustomer') 132 download_name = u'scan.pdf' 133 134 @property 135 def download_filename(self): 136 return u"%s" % self.context.document_id[:9] 137 138 class PDFScanSlip(PDFScanDisplay): 139 grok.view(PDFDocumentSlip) -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/interfaces.py
r14181 r14184 20 20 from waeup.ikoba.interfaces import IIkobaObject 21 21 from waeup.ikoba.customers.interfaces import ( 22 ICustomer, ICustomerDocument, IC ontract)22 ICustomer, ICustomerDocument, ICustomerPDFDocument, IContract) 23 23 from waeup.ikoba.customers.vocabularies import ( 24 24 ConCatProductSource, CustomerDocumentSource) … … 40 40 """ 41 41 42 class IUnibenCustomerPDFDocument(ICustomerPDFDocument): 43 """A customer pdf document. 44 45 """ 46 42 47 # Customer contract interfaces 43 48 … … 53 58 ) 54 59 55 class IUnibenContractOfficialUse(IIkobaObject): 56 """Interface for editing official use data. 60 document_object2 = schema.Choice( 61 title = _(u'Document 2'), 62 source = CustomerDocumentSource(), 63 required = False, 64 ) 65 66 class IRIAAContract(IUnibenContract): 67 """A Retention of Name contract. 68 69 """ 70 71 class IRIAAContractOfficialUse(IIkobaObject): 72 """Interface for editing RIAA official use data. 57 73 58 74 """ … … 63 79 ) 64 80 65 class IUnibenContractProcess(IUnibenContract, IUnibenContractOfficialUse): 66 """Interface for processing contract data. 81 82 class IRIAAContractProcess(IRIAAContract, IRIAAContractOfficialUse): 83 """Interface for processing RIAA data. 67 84 """ 68 85 … … 72 89 required = False, 73 90 readonly = False, 74 default = [],91 defaultFactory=list, 75 92 ) 76 93 77 class I UnibenContractEdit(IUnibenContract):78 """Interface for editing sample contractdata by customers.94 class IRIAAContractEdit(IRIAAContract): 95 """Interface for editing RIAA data by customers. 79 96 80 97 """ … … 85 102 required = True, 86 103 ) 104 105 document_object2 = schema.Choice( 106 title = _(u'Document 2'), 107 source = CustomerDocumentSource(), 108 required = True, 109 ) -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/tests/test_browser.py
r14181 r14184 33 33 UnibenCustomerExporter, 34 34 UnibenCustomerDocumentExporter, 35 UnibenContractExporter)35 RIAAContractExporter) 36 36 from ikobacustom.uniben.customers.batching import ( 37 37 UnibenCustomerProcessor, 38 38 UnibenCustomerDocumentProcessor, 39 UnibenContractProcessor)39 RIAAContractProcessor) 40 40 from ikobacustom.uniben.testing import FunctionalLayer, samples_dir 41 41 … … 49 49 50 50 def setup_customizable_params(self): 51 self._contract_category = u' sample'51 self._contract_category = u'riaa' 52 52 return 53 53 … … 64 64 document.title = u'My first document' 65 65 customer['documents'].addDocument(document) 66 contract = createObject(u'waeup. UnibenContract')66 contract = createObject(u'waeup.RIAAContract') 67 67 contract.tc_dict = {'en':u'Hello World'} 68 68 customer['contracts'].addContract(contract) … … 162 162 # set values we can expect in export file 163 163 self.setup_for_export() 164 exporter = UnibenContractExporter()164 exporter = RIAAContractExporter() 165 165 exporter.export_all(self.app, self.outfile) 166 166 result = open(self.outfile, 'rb').read() … … 169 169 'fee_based,history,last_product_id,product_object,product_options,' 170 170 'state,tc_dict,title,user_id,valid_from,valid_to\r\n' 171 ' UnibenContract,,sample,%s,,0,'171 'RIAAContract,,riaa,%s,,0,' 172 172 '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']' 173 173 ',,,[],created,{\'en\': u\'Hello World\'},,K1000000,,\r\n' 174 174 % self.contract.contract_id) 175 175 # We can reimport the file if we change the header (user_id -> customer_id) 176 processor = UnibenContractProcessor()176 processor = RIAAContractProcessor() 177 177 open(self.outfile, 'wb').write( 178 178 'class_name,contract_category,contract_id,document_object,' 179 179 'history,last_product_id,product_object,product_options,' 180 180 'state,tc_dict,title,user_id\r\n' 181 ' UnibenContract,sample,%s,,'181 'RIAAContract,riaa,%s,,' 182 182 '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']' 183 183 ',,,[],created,{\'en\': u\'Hello World\'},,K1000000\r\n' … … 220 220 221 221 def setup_customizable_params(self): 222 self._contract_category = u' sample'222 self._contract_category = u'riaa' 223 223 self._document_factory = 'waeup.UnibenCustomerDocument' 224 self._contract_factory = 'waeup. UnibenContract'224 self._contract_factory = 'waeup.RIAAContract' 225 225 return 226 226 … … 303 303 304 304 def setup_customizable_params(self): 305 self._contract_category = u' sample'305 self._contract_category = u'riaa' 306 306 self._document_factory = 'waeup.UnibenCustomerDocument' 307 self._contract_factory = 'waeup. UnibenContract'307 self._contract_factory = 'waeup.RIAAContract' 308 308 return 309 309 -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/tests/test_contract.py
r14181 r14184 29 29 30 30 from ikobacustom.uniben.testing import (FunctionalLayer, FunctionalTestCase) 31 from ikobacustom.uniben.customers.contracts import UnibenContract32 from ikobacustom.uniben.customers.interfaces import I UnibenContract31 from ikobacustom.uniben.customers.contracts import RIAAContract 32 from ikobacustom.uniben.customers.interfaces import IRIAAContract 33 33 34 34 … … 38 38 39 39 def test_interfaces(self): 40 verify.verifyClass(I UnibenContract, UnibenContract)41 verify.verifyClass(ICustomerNavigation, UnibenContract)42 verify.verifyObject(I UnibenContract, UnibenContract())43 verify.verifyObject(ICustomerNavigation, UnibenContract())40 verify.verifyClass(IRIAAContract, RIAAContract) 41 verify.verifyClass(ICustomerNavigation, RIAAContract) 42 verify.verifyObject(IRIAAContract, RIAAContract()) 43 verify.verifyObject(ICustomerNavigation, RIAAContract()) 44 44 return 45 45 46 46 def test_addContract(self): 47 47 container = ContractsContainer() 48 contract = createObject(u'waeup. UnibenContract')48 contract = createObject(u'waeup.RIAAContract') 49 49 id = contract.contract_id 50 50 container.addContract(contract) 51 51 self.assertEqual(container[id], contract) 52 52 self.assertRaises(TypeError, container.addContract, object()) 53 self.assertEqual(contract.class_name, ' UnibenContract')53 self.assertEqual(contract.class_name, 'RIAAContract') 54 54 return -
main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/utils.py
r14181 r14184 33 33 #: A prefix used when generating new customer ids. Each customer id will 34 34 #: start with this string. The default is 'K'. 35 CUSTOMER_ID_PREFIX = u' K'35 CUSTOMER_ID_PREFIX = u'B' 36 36 37 37 DOCMANAGE_CUSTOMER_STATES = (REQUESTED, APPROVED, PROVISIONALLY) … … 44 44 45 45 DOCTYPES_DICT = { 46 #'CustomerSampleDocument': _('Sample Document'), 47 #'CustomerPDFDocument': _('PDF Document'), 48 49 'UnibenCustomerDocument': _('Uniben Document'), 46 #'UnibenCustomerDocument': _('Uniben Document'), 47 'UnibenCustomerPDFDocument': _('Uniben PDF Document'), 50 48 } 51 49 52 50 CONTYPES_DICT = { 53 #'SampleContract': _('Sample Contract'), 54 55 'UnibenContract': _('Uniben Contract'), 51 'RIAAContract': _('RIAA Contract'), 56 52 } 57 53 … … 62 58 EXPORTER_NAMES = ( 63 59 'customers', 64 'unibencustomer documents',65 ' unibencontracts')60 'unibencustomerpdfdocuments', 61 'riaacontracts')
Note: See TracChangeset for help on using the changeset viewer.