Changeset 12057
- Timestamp:
- 25 Nov 2014, 13:15:27 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12056 r12057 376 376 name = _('CustomerDocument Processor') 377 377 iface = ICustomerDocument 378 factory_name = 'waeup.Customer Document'378 factory_name = 'waeup.CustomerSampleDocument' 379 379 380 380 location_fields = [] -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
r12056 r12057 59 59 CustomerDocumentsContainer = attrs_to_fields(CustomerDocumentsContainer) 60 60 61 class CustomerDocument (Document):62 """This is a customer document .61 class CustomerDocumentBase(Document): 62 """This is a customer document baseclass. 63 63 """ 64 64 grok.implements(ICustomerDocument, ICustomerNavigation) 65 65 grok.provides(ICustomerDocument) 66 67 def __init__(self): 68 super(CustomerDocument, self).__init__() 69 return 66 grok.baseclass() 70 67 71 68 @property … … 102 99 return 103 100 104 CustomerDocument = attrs_to_fields(CustomerDocument) 105 106 class CustomerPDFDocument(CustomerDocument): 107 """This is a customer document for a single pdf upload file only. 101 102 class CustomerSampleDocument(CustomerDocumentBase): 103 """This is a sample customer document. 104 """ 105 106 CustomerSampleDocument = attrs_to_fields(CustomerSampleDocument) 107 108 109 class CustomerPDFDocument(CustomerDocumentBase): 110 """This is a customer document for a single pdf upload file. 108 111 """ 109 112 grok.implements(ICustomerPDFDocument, ICustomerNavigation) … … 118 121 """ 119 122 grok.implements(IFactory) 120 grok.name(u'waeup.Customer Document')123 grok.name(u'waeup.CustomerSampleDocument') 121 124 title = u"Create a new document.", 122 125 description = u"This factory instantiates new sample document instances." 123 126 124 127 def __call__(self, *args, **kw): 125 return Customer Document(*args, **kw)128 return CustomerSampleDocument(*args, **kw) 126 129 127 130 def getInterfaces(self): 128 return implementedBy(Customer Document)131 return implementedBy(CustomerSampleDocument) 129 132 130 133 # Customer documents must be importable. So we might need a factory. -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/fileviewlets.py
r12050 r12057 32 32 33 33 from waeup.ikoba.customers.interfaces import ( 34 ICustomer, ICustomersUtils, ICustomerDocument) 34 ICustomer, ICustomersUtils) 35 36 from waeup.ikoba.customers.documents import ( 37 CustomerSampleDocument, CustomerPDFDocument 38 ) 35 39 from waeup.ikoba.customers.browser import ( 36 40 CustomerBaseDisplayFormPage, CustomerBaseManageFormPage, … … 258 262 # File viewlets for customer documents 259 263 260 class S canManageUpload(FileUpload):264 class SampleManageUpload(FileUpload): 261 265 """Scan upload viewlet for officers. 262 266 """ 263 267 grok.order(1) 264 grok.context( ICustomerDocument)268 grok.context(CustomerSampleDocument) 265 269 grok.view(DocumentManageFormPage) 266 270 grok.require('waeup.manageCustomer') 267 label = _(u'S can')268 title = _(u'S can')271 label = _(u'Sample Scan') 272 title = _(u'Sample Scan') 269 273 mus = 1024 * 50 270 download_name = u's can'274 download_name = u'sample' 271 275 tab_redirect = '#tab2' 272 276 273 277 274 class S canEditUpload(ScanManageUpload):278 class SampleEditUpload(SampleManageUpload): 275 279 """Scan upload viewlet for customer. 276 280 """ … … 279 283 280 284 281 class S canDisplay(FileDisplay):285 class SampleDisplay(FileDisplay): 282 286 """Scan display viewlet. 283 287 """ 284 288 grok.order(1) 285 grok.context( ICustomerDocument)289 grok.context(CustomerSampleDocument) 286 290 grok.require('waeup.viewCustomer') 287 291 grok.view(DocumentDisplayFormPage) 288 label = _(u'S can')289 title = _(u'S can')290 download_name = u's can'291 292 293 class S canImage(Image):292 label = _(u'Sample Scan') 293 title = _(u'Sample Scan') 294 download_name = u'sample' 295 296 297 class SampleScanImage(Image): 294 298 """Scan document. 295 299 """ 296 grok.name('scan') 297 grok.context(ICustomerDocument) 298 grok.require('waeup.viewCustomer') 299 download_name = u'scan' 300 grok.name('sample') 301 grok.context(CustomerSampleDocument) 302 grok.require('waeup.viewCustomer') 303 download_name = u'sample' 304 305 306 class PDFManageUpload(FileUpload): 307 """Scan upload viewlet for officers. 308 """ 309 grok.view(DocumentManageFormPage) 310 grok.context(CustomerPDFDocument) 311 grok.require('waeup.manageCustomer') 312 label = _(u'PDF File') 313 title = _(u'PDF File') 314 mus = 1024 * 200 315 download_name = u'pdffile' 316 tab_redirect = '#tab2' 317 318 319 class PDFEditUpload(PDFManageUpload): 320 """Scan upload viewlet for customer. 321 """ 322 grok.view(DocumentEditFormPage) 323 grok.require('waeup.handleCustomer') 324 325 326 class PDFDisplay(FileDisplay): 327 """Scan display viewlet. 328 """ 329 grok.order(1) 330 grok.context(CustomerPDFDocument) 331 grok.require('waeup.viewCustomer') 332 grok.view(DocumentDisplayFormPage) 333 label = _(u'PDF Scan') 334 title = _(u'PDF Scan') 335 download_name = u'pdf' 336 337 338 class PDFScanImage(Image): 339 """Scan document. 340 """ 341 grok.name('pdf') 342 grok.context(CustomerPDFDocument) 343 grok.require('waeup.viewCustomer') 344 download_name = u'pdf' -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12056 r12057 269 269 """ 270 270 271 is_editable = Attribute('Document editable by customer')272 translated_class_name = Attribute('Translatable class name')271 #is_editable = Attribute('Document editable by customer') 272 #translated_class_name = Attribute('Translatable class name') 273 273 274 274 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_document_data.csv
r12056 r12057 1 1 class_name,document_id,reg_number,title 2 Customer Document,d3,1,My first doc3 Customer Document,d4,2,My second doc4 Customer Document,d5,3,My third doc5 Customer Document,,1,My 4th doc6 Customer Document,d5,2,My stolen doc2 CustomerSampleDocument,d3,1,My first doc 3 CustomerSampleDocument,d4,2,My second doc 4 CustomerSampleDocument,d5,3,My third doc 5 CustomerSampleDocument,,1,My 4th doc 6 CustomerSampleDocument,d5,2,My stolen doc -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r12056 r12057 38 38 CustomerProcessor, CustomerDocumentProcessor) 39 39 from waeup.ikoba.customers.customer import Customer 40 from waeup.ikoba.customers.documents import Customer Document40 from waeup.ikoba.customers.documents import CustomerSampleDocument 41 41 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 42 42 … … 117 117 customer.nationality = u'NG' 118 118 119 document = Customer Document()119 document = CustomerSampleDocument() 120 120 document.title = u'My Document' 121 121 customer['documents'].addDocument(document) … … 262 262 self.app['customers'].addCustomer(customer) 263 263 self.customer = self.app['customers'][customer.customer_id] 264 document = createObject(u'waeup.Customer Document')264 document = createObject(u'waeup.CustomerSampleDocument') 265 265 document.document_id = 'd120' 266 266 self.customer['documents'][document.document_id] = document … … 306 306 def test_addEntry(self): 307 307 self.assertEqual(len(self.customer['documents'].keys()),1) 308 document1 = createObject(u'waeup.Customer Document')308 document1 = createObject(u'waeup.CustomerSampleDocument') 309 309 document1.document_id = 'p234' 310 310 self.processor.addEntry( … … 313 313 self.assertEqual(len(self.customer['documents'].keys()),2) 314 314 self.assertEqual(self.customer['documents']['p234'].document_id, 'p234') 315 document2 = createObject(u'waeup.Customer Document')315 document2 = createObject(u'waeup.CustomerSampleDocument') 316 316 document1.document_id = 'nonsense' 317 317 318 318 def test_checkConversion(self): 319 319 errs, inv_errs, conv_dict = self.processor.checkConversion( 320 dict(document_id='d1266236341955', class_name='Customer Document'))320 dict(document_id='d1266236341955', class_name='CustomerSampleDocument')) 321 321 self.assertEqual(len(errs),0) 322 322 errs, inv_errs, conv_dict = self.processor.checkConversion( 323 dict(document_id='nonsense', class_name='Customer Document'))323 dict(document_id='nonsense', class_name='CustomerSampleDocument')) 324 324 self.assertEqual(len(errs),1) 325 325 timestamp = ("%d" % int(time()*10000))[1:] 326 326 document_id = "d%s" % timestamp 327 327 errs, inv_errs, conv_dict = self.processor.checkConversion( 328 dict(document_id=document_id, class_name='Customer Document'))328 dict(document_id=document_id, class_name='CustomerSampleDocument')) 329 329 self.assertEqual(len(errs),0) 330 330 errs, inv_errs, conv_dict = self.processor.checkConversion( … … 340 340 self.assertEqual(fail_file, 341 341 'class_name,reg_number,document_id,title,--ERRORS--\r\n' 342 'Customer Document,2,d5,My stolen doc,document_id: id exists\r\n')342 'CustomerSampleDocument,2,d5,My stolen doc,document_id: id exists\r\n') 343 343 document = self.processor.getEntry(dict(reg_number='1', 344 344 document_id='d3'), self.app) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12053 r12057 103 103 self.customer_id = customer.customer_id 104 104 self.customer = self.app['customers'][self.customer_id] 105 document = createObject('waeup.Customer Document')105 document = createObject('waeup.CustomerSampleDocument') 106 106 document.title = u'My first document' 107 107 self.customer['documents'].addDocument(document) … … 800 800 801 801 class DocumentUITests(CustomersFullSetup): 802 # Tests for Customer Document relates views and pages802 # Tests for CustomerSampleDocument relates views and pages 803 803 804 804 def test_manage_document(self): … … 871 871 self.browser.getLink("Documents").click() 872 872 self.browser.getLink("Add document").click() 873 self.browser.getControl(name="doctype").value = ['Customer Document']873 self.browser.getControl(name="doctype").value = ['CustomerSampleDocument'] 874 874 self.browser.getControl("Create document").click() 875 875 self.assertTrue('Sample Document created.' in self.browser.contents) … … 892 892 # Costumer can upload a document. 893 893 self.browser.getLink("Edit").click() 894 ctrl = self.browser.getControl(name='s caneditupload')894 ctrl = self.browser.getControl(name='sampleeditupload') 895 895 file_obj = open(SAMPLE_IMAGE, 'rb') 896 896 file_ctrl = ctrl.mech_control 897 897 file_ctrl.add_file(file_obj, filename='my_document.jpg') 898 898 self.browser.getControl( 899 name='upload_s caneditupload').click()900 self.assertTrue( 901 'href="http://localhost/app/customers/K1000000/documents/d102/s can"'899 name='upload_sampleeditupload').click() 900 self.assertTrue( 901 'href="http://localhost/app/customers/K1000000/documents/d102/sample"' 902 902 in self.browser.contents) 903 903 # Costumer can submit the form. The form is also saved. … … 918 918 # Create a pseudo image file and select it to be uploaded 919 919 image = open(SAMPLE_IMAGE, 'rb') 920 ctrl = self.browser.getControl(name='s canmanageupload')920 ctrl = self.browser.getControl(name='samplemanageupload') 921 921 file_ctrl = ctrl.mech_control 922 file_ctrl.add_file(image, filename='my_s can.jpg')922 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 923 923 # The Save action does not upload files 924 924 self.browser.getControl("Save").click() # submit form 925 925 self.assertFalse( 926 'href="http://localhost/app/customers/K1000000/documents/d101/s can"'926 'href="http://localhost/app/customers/K1000000/documents/d101/sample"' 927 927 in self.browser.contents) 928 928 # ... but the correct upload submit button does 929 929 image = open(SAMPLE_IMAGE) 930 ctrl = self.browser.getControl(name='s canmanageupload')930 ctrl = self.browser.getControl(name='samplemanageupload') 931 931 file_ctrl = ctrl.mech_control 932 file_ctrl.add_file(image, filename='my_s can.jpg')933 self.browser.getControl( 934 name='upload_s canmanageupload').click()935 self.assertTrue( 936 'href="http://localhost/app/customers/K1000000/documents/d101/s can"'932 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 933 self.browser.getControl( 934 name='upload_samplemanageupload').click() 935 self.assertTrue( 936 'href="http://localhost/app/customers/K1000000/documents/d101/sample"' 937 937 in self.browser.contents) 938 938 # Browsing the link shows a real image 939 self.browser.open('s can')939 self.browser.open('sample') 940 940 self.assertEqual( 941 941 self.browser.headers['content-type'], 'image/jpeg') … … 944 944 self.browser.open(self.customer_path + '/documents/d101/manage') 945 945 self.assertFalse( 946 'upload_s canmanageupload' in self.browser.contents)946 'upload_samplemanageupload' in self.browser.contents) 947 947 # File must be deleted first 948 self.browser.getControl(name='delete_s canmanageupload').click()949 self.assertTrue( 950 's candeleted' in self.browser.contents)948 self.browser.getControl(name='delete_samplemanageupload').click() 949 self.assertTrue( 950 'sample deleted' in self.browser.contents) 951 951 # Uploading a file which is bigger than 150k will raise an error 952 952 big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75) 953 ctrl = self.browser.getControl(name='s canmanageupload')953 ctrl = self.browser.getControl(name='samplemanageupload') 954 954 file_ctrl = ctrl.mech_control 955 file_ctrl.add_file(big_image, filename='my_s can.jpg')956 self.browser.getControl( 957 name='upload_s canmanageupload').click()955 file_ctrl.add_file(big_image, filename='my_sample_scan.jpg') 956 self.browser.getControl( 957 name='upload_samplemanageupload').click() 958 958 self.assertTrue( 959 959 'Uploaded file is too big' in self.browser.contents) 960 960 # we do not rely on filename extensions given by uploaders 961 961 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 962 ctrl = self.browser.getControl(name='s canmanageupload')962 ctrl = self.browser.getControl(name='samplemanageupload') 963 963 file_ctrl = ctrl.mech_control 964 964 # tell uploaded file is bmp 965 file_ctrl.add_file(image, filename='my_s can.bmp')966 self.browser.getControl( 967 name='upload_s canmanageupload').click()965 file_ctrl.add_file(image, filename='my_sample_scan.bmp') 966 self.browser.getControl( 967 name='upload_samplemanageupload').click() 968 968 self.assertTrue( 969 969 # jpg file was recognized 970 'File s can.jpg uploaded.' in self.browser.contents)970 'File sample.jpg uploaded.' in self.browser.contents) 971 971 # Delete file again 972 self.browser.getControl(name='delete_s canmanageupload').click()973 self.assertTrue( 974 's candeleted' in self.browser.contents)972 self.browser.getControl(name='delete_samplemanageupload').click() 973 self.assertTrue( 974 'sample deleted' in self.browser.contents) 975 975 # File names must meet several conditions 976 976 bmp_image = open(SAMPLE_IMAGE_BMP, 'rb') 977 ctrl = self.browser.getControl(name='s canmanageupload')977 ctrl = self.browser.getControl(name='samplemanageupload') 978 978 file_ctrl = ctrl.mech_control 979 file_ctrl.add_file(bmp_image, filename='my_s can.bmp')980 self.browser.getControl( 981 name='upload_s canmanageupload').click()979 file_ctrl.add_file(bmp_image, filename='my_sample_scan.bmp') 980 self.browser.getControl( 981 name='upload_samplemanageupload').click() 982 982 self.assertTrue('Only the following extensions are allowed' 983 983 in self.browser.contents) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py
r12056 r12057 27 27 from waeup.ikoba.interfaces import IObjectHistory 28 28 from waeup.ikoba.customers.documents import ( 29 CustomerDocumentsContainer, Customer Document)29 CustomerDocumentsContainer, CustomerSampleDocument) 30 30 from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase) 31 31 … … 46 46 self.assertTrue( 47 47 verifyClass( 48 ICustomerDocument, Customer Document)48 ICustomerDocument, CustomerSampleDocument) 49 49 ) 50 50 self.assertTrue( 51 51 verifyObject( 52 ICustomerDocument, Customer Document())52 ICustomerDocument, CustomerSampleDocument()) 53 53 ) 54 54 return … … 56 56 def test_addDocument(self): 57 57 container = CustomerDocumentsContainer() 58 document = createObject(u'waeup.Customer Document')58 document = createObject(u'waeup.CustomerSampleDocument') 59 59 id = document.document_id 60 60 container.addDocument(document) 61 61 self.assertEqual(container[id], document) 62 62 self.assertRaises(TypeError, container.addDocument, object()) 63 self.assertEqual(document.class_name, 'Customer Document')63 self.assertEqual(document.class_name, 'CustomerSampleDocument') 64 64 return 65 65 66 66 def test_document_workflow(self): 67 document = createObject(u'waeup.Customer Document')67 document = createObject(u'waeup.CustomerSampleDocument') 68 68 IWorkflowInfo(document).fireTransition('create') 69 69 self.assertEqual(IWorkflowState(document).getState(), 'created') … … 82 82 83 83 def test_document_history(self): 84 doc = createObject(u'waeup.Customer Document')84 doc = createObject(u'waeup.CustomerSampleDocument') 85 85 IWorkflowInfo(doc).fireTransition('create') 86 86 messages = ' '.join(doc.history.messages) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r12056 r12057 13 13 from waeup.ikoba.customers.interfaces import ICSVCustomerExporter 14 14 from waeup.ikoba.customers.customer import Customer 15 from waeup.ikoba.customers.documents import Customer Document15 from waeup.ikoba.customers.documents import CustomerSampleDocument 16 16 from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup 17 17 from waeup.ikoba.testing import FunctionalLayer … … 132 132 def test_export_empty(self): 133 133 # we can export a nearly empty document 134 document = Customer Document()134 document = CustomerSampleDocument() 135 135 exporter = CustomerDocumentsExporter() 136 136 exporter.export([document], self.outfile) … … 139 139 result, 140 140 'class_name,document_id,history,last_transition_date,state,title,customer_id\r\n' 141 'Customer Document,d101,[],,,,\r\n'141 'CustomerSampleDocument,d101,[],,,,\r\n' 142 142 ) 143 143 return … … 156 156 ) 157 157 self.assertMatches( 158 '...Customer Document,d101,[u\'2014-11-25 06:57:24 UTC - '158 '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - ' 159 159 'Document created by system\'],2014-11-25 06:57:24.990308#,' 160 160 'created,My Document,A111111...', … … 174 174 in result) 175 175 self.assertMatches( 176 '...Customer Document,d101,[u\'2014-11-25 06:57:24 UTC - '176 '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - ' 177 177 'Document created by system\'],2014-11-25 06:57:24.990308#,' 178 178 'created,My Document,A111111...', … … 192 192 in result) 193 193 self.assertMatches( 194 '...Customer Document,d101,[u\'2014-11-25 06:57:24 UTC - '194 '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - ' 195 195 'Document created by system\'],2014-11-25 06:57:24.990308#,' 196 196 'created,My Document,A111111...', -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12053 r12057 289 289 290 290 DOCTYPES_DICT = { 291 'Customer Document': 'Sample Document',291 'CustomerSampleDocument': 'Sample Document', 292 292 'CustomerPDFDocument': 'PDF Document', 293 293 }
Note: See TracChangeset for help on using the changeset viewer.