Changeset 12062 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Timestamp:
- 26 Nov 2014, 13:03:56 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12059 r12062 50 50 from waeup.ikoba.customers.interfaces import ( 51 51 ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils, 52 ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate 52 ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate, 53 ICustomerPDFDocument 53 54 ) 54 55 from waeup.ikoba.customers.catalog import search … … 932 933 return 933 934 934 class ExportPDFDocumentsOverviewPage(UtilityView, grok.View):935 class PDFDocumentsOverviewPage(UtilityView, grok.View): 935 936 """Deliver an overview slip. 936 937 """ … … 988 989 tabledata=tabledata, 989 990 omit_fields=self.omit_fields) 991 992 993 class PDFDocumentSlipPage(UtilityView, grok.View): 994 """Deliver pdf file including metadata. 995 """ 996 grok.context(ICustomerDocument) 997 grok.name('document_slip.pdf') 998 grok.require('waeup.viewCustomer') 999 prefix = 'form' 1000 1001 omit_fields = ('suspended', 'sex', 1002 'suspended_comment',) 1003 1004 #form_fields = grok.AutoFields(ICustomerPDFDocument).omit( 1005 # 'last_transition_date') 1006 form_fields =() 1007 1008 @property 1009 def label(self): 1010 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 1011 return '%s of %s\nTitle: %s' % ( 1012 self.context.translated_class_name, 1013 self.context.customer.display_fullname, 1014 self.context.title) 1015 1016 def render(self): 1017 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 1018 customerview = CustomerBasePDFFormPage(self.context.customer, 1019 self.request, self.omit_fields) 1020 customers_utils = getUtility(ICustomersUtils) 1021 return customers_utils.renderPDF( 1022 self, 'document_slip.pdf', 1023 self.context.customer, customerview, 1024 omit_fields=self.omit_fields) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/fileviewlets.py
r12058 r12062 41 41 CustomerFilesUploadPage, 42 42 DocumentDisplayFormPage, DocumentManageFormPage, DocumentEditFormPage, 43 ExportPDFDocumentsOverviewPage)43 PDFDocumentSlipPage,) 44 44 45 45 grok.context(IIkobaObject) # Make IIkobaObject the default context … … 262 262 # File viewlets for customer documents 263 263 264 class Sample ManageUpload(FileUpload):264 class SampleScanManageUpload(FileUpload): 265 265 """Scan upload viewlet for officers. 266 266 """ … … 276 276 277 277 278 class Sample EditUpload(SampleManageUpload):278 class SampleScanEditUpload(SampleScanManageUpload): 279 279 """Scan upload viewlet for customer. 280 280 """ … … 283 283 284 284 285 class Sample Display(FileDisplay):285 class SampleScanDisplay(FileDisplay): 286 286 """Scan display viewlet. 287 287 """ … … 303 303 download_name = u'sample' 304 304 305 306 class PDFManageUpload(FileUpload): 305 class SampleScanPDFSlip(SampleScanDisplay): 306 grok.view(PDFDocumentSlipPage) 307 308 309 class PDFScanManageUpload(FileUpload): 307 310 """Scan upload viewlet for officers. 308 311 """ … … 317 320 318 321 319 class PDF EditUpload(PDFManageUpload):322 class PDFScanEditUpload(PDFScanManageUpload): 320 323 """Scan upload viewlet for customer. 321 324 """ … … 324 327 325 328 326 class PDF Display(FileDisplay):329 class PDFScanDisplay(FileDisplay): 327 330 """Scan display viewlet. 328 331 """ … … 343 346 grok.require('waeup.viewCustomer') 344 347 download_name = u'sample.pdf' 348 349 class PDFScanSlip(PDFScanDisplay): 350 grok.view(PDFDocumentSlipPage) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12059 r12062 893 893 # Costumer can upload a document. 894 894 self.browser.getLink("Edit").click() 895 ctrl = self.browser.getControl(name='sample editupload')895 ctrl = self.browser.getControl(name='samplescaneditupload') 896 896 file_obj = open(SAMPLE_IMAGE, 'rb') 897 897 file_ctrl = ctrl.mech_control 898 898 file_ctrl.add_file(file_obj, filename='my_document.jpg') 899 899 self.browser.getControl( 900 name='upload_sample editupload').click()900 name='upload_samplescaneditupload').click() 901 901 self.assertTrue( 902 902 'href="http://localhost/app/customers/K1000000/documents/d102/sample"' … … 919 919 # Create a pseudo image file and select it to be uploaded 920 920 image = open(SAMPLE_IMAGE, 'rb') 921 ctrl = self.browser.getControl(name='sample manageupload')921 ctrl = self.browser.getControl(name='samplescanmanageupload') 922 922 file_ctrl = ctrl.mech_control 923 923 file_ctrl.add_file(image, filename='my_sample_scan.jpg') … … 929 929 # ... but the correct upload submit button does 930 930 image = open(SAMPLE_IMAGE) 931 ctrl = self.browser.getControl(name='sample manageupload')931 ctrl = self.browser.getControl(name='samplescanmanageupload') 932 932 file_ctrl = ctrl.mech_control 933 933 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 934 934 self.browser.getControl( 935 name='upload_sample manageupload').click()935 name='upload_samplescanmanageupload').click() 936 936 self.assertTrue( 937 937 'href="http://localhost/app/customers/K1000000/documents/d101/sample"' … … 945 945 self.browser.open(self.customer_path + '/documents/d101/manage') 946 946 self.assertFalse( 947 'upload_sample manageupload' in self.browser.contents)947 'upload_samplescanmanageupload' in self.browser.contents) 948 948 # File must be deleted first 949 self.browser.getControl(name='delete_sample manageupload').click()949 self.browser.getControl(name='delete_samplescanmanageupload').click() 950 950 self.assertTrue( 951 951 'sample deleted' in self.browser.contents) 952 952 # Uploading a file which is bigger than 150k will raise an error 953 953 big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75) 954 ctrl = self.browser.getControl(name='sample manageupload')954 ctrl = self.browser.getControl(name='samplescanmanageupload') 955 955 file_ctrl = ctrl.mech_control 956 956 file_ctrl.add_file(big_image, filename='my_sample_scan.jpg') 957 957 self.browser.getControl( 958 name='upload_sample manageupload').click()958 name='upload_samplescanmanageupload').click() 959 959 self.assertTrue( 960 960 'Uploaded file is too big' in self.browser.contents) 961 961 # we do not rely on filename extensions given by uploaders 962 962 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 963 ctrl = self.browser.getControl(name='sample manageupload')963 ctrl = self.browser.getControl(name='samplescanmanageupload') 964 964 file_ctrl = ctrl.mech_control 965 965 # tell uploaded file is bmp 966 966 file_ctrl.add_file(image, filename='my_sample_scan.bmp') 967 967 self.browser.getControl( 968 name='upload_sample manageupload').click()968 name='upload_samplescanmanageupload').click() 969 969 self.assertTrue( 970 970 # jpg file was recognized 971 971 'File sample.jpg uploaded.' in self.browser.contents) 972 972 # Delete file again 973 self.browser.getControl(name='delete_sample manageupload').click()973 self.browser.getControl(name='delete_samplescanmanageupload').click() 974 974 self.assertTrue( 975 975 'sample deleted' in self.browser.contents) 976 976 # File names must meet several conditions 977 977 bmp_image = open(SAMPLE_IMAGE_BMP, 'rb') 978 ctrl = self.browser.getControl(name='sample manageupload')978 ctrl = self.browser.getControl(name='samplescanmanageupload') 979 979 file_ctrl = ctrl.mech_control 980 980 file_ctrl.add_file(bmp_image, filename='my_sample_scan.bmp') 981 981 self.browser.getControl( 982 name='upload_sample manageupload').click()982 name='upload_samplescanmanageupload').click() 983 983 self.assertTrue('Only the following extensions are allowed' 984 984 in self.browser.contents) … … 995 995 # Create a pseudo image file and select it to be uploaded 996 996 image = open(SAMPLE_IMAGE, 'rb') 997 ctrl = self.browser.getControl(name='pdf manageupload')997 ctrl = self.browser.getControl(name='pdfscanmanageupload') 998 998 file_ctrl = ctrl.mech_control 999 999 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 1000 1000 self.browser.getControl( 1001 name='upload_pdf manageupload').click()1001 name='upload_pdfscanmanageupload').click() 1002 1002 self.assertTrue( 1003 1003 'pdf file extension expected' in self.browser.contents) 1004 ctrl = self.browser.getControl(name='pdf manageupload')1004 ctrl = self.browser.getControl(name='pdfscanmanageupload') 1005 1005 file_ctrl = ctrl.mech_control 1006 1006 file_ctrl.add_file(image, filename='my_sample_scan.pdf') 1007 1007 self.browser.getControl( 1008 name='upload_pdf manageupload').click()1008 name='upload_pdfscanmanageupload').click() 1009 1009 self.assertTrue( 1010 1010 'Could not determine file type' in self.browser.contents) 1011 1011 pdf = open(SAMPLE_PDF, 'rb') 1012 ctrl = self.browser.getControl(name='pdf manageupload')1012 ctrl = self.browser.getControl(name='pdfscanmanageupload') 1013 1013 file_ctrl = ctrl.mech_control 1014 1014 file_ctrl.add_file(pdf, filename='my_sample_scan.pdf') 1015 1015 self.browser.getControl( 1016 name='upload_pdf manageupload').click()1016 name='upload_pdfscanmanageupload').click() 1017 1017 self.assertTrue( 1018 1018 'href="http://localhost/app/customers/K1000000/documents/d102/sample.pdf">PDF File</a>' … … 1025 1025 def test_view_slips(self): 1026 1026 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1027 # Officers can open the pdf transcript1027 # Officers can open the document overview 1028 1028 self.browser.open(self.customer_path + '/documents') 1029 1029 self.browser.getLink("Download documents overview").click() … … 1033 1033 open(path, 'wb').write(self.browser.contents) 1034 1034 print "Sample PDF overview_slip.pdf written to %s" % path 1035 # Officers can open document slips 1036 self.browser.open(self.customer_path + '/documents/d101') 1037 self.browser.getLink("Download document slip").click() 1038 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1039 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1040 path = os.path.join(samples_dir(), 'document_slip.pdf') 1041 open(path, 'wb').write(self.browser.contents) 1042 print "Sample document_slip.pdf written to %s" % path -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12057 r12062 232 232 fm.update() 233 233 if fm.viewlets: 234 sc_translation = trans(_(' Scanned Documents'), lang)234 sc_translation = trans(_('Connected Files'), lang) 235 235 data.append(Paragraph(sc_translation, HEADING_STYLE)) 236 236 # Insert list of scanned documents … … 350 350 # Insert history 351 351 if show_history: 352 hist_translation = trans(_('Workflow History'), portal_language) 353 data.append(Paragraph(hist_translation, HEADING_STYLE)) 354 data.extend(creator.fromStringList(customer.history.messages)) 352 if getattr(view.context, 'history', None): 353 hist_translation = trans(_('Document Workflow History'), portal_language) 354 data.append(Paragraph(hist_translation, HEADING_STYLE)) 355 data.extend(creator.fromStringList(view.context.history.messages)) 356 else: 357 hist_translation = trans(_('Customer Workflow History'), portal_language) 358 data.append(Paragraph(hist_translation, HEADING_STYLE)) 359 data.extend(creator.fromStringList(customer.history.messages)) 355 360 356 361 # Insert content tables (optionally on second page) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py
r12059 r12062 298 298 299 299 300 class PDF SlipActionButton(ManageActionButton):300 class PDFOverviewActionButton(ManageActionButton): 301 301 grok.order(2) 302 302 grok.context(ICustomerDocumentsContainer) … … 350 350 target = 'index' 351 351 icon = 'actionicon_view.png' 352 353 class PDFSlipActionButton(ManageActionButton): 354 grok.order(3) 355 grok.context(ICustomerDocument) 356 grok.view(DocumentDisplayFormPage) 357 grok.require('waeup.viewCustomer') 358 icon = 'actionicon_pdf.png' 359 text = _('Download document slip') 360 target = 'document_slip.pdf'
Note: See TracChangeset for help on using the changeset viewer.