Changeset 12444 for main/waeup.ikoba/trunk/src
- Timestamp:
- 11 Jan 2015, 22:43:35 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/fileviewlets.py
r12386 r12444 109 109 label = _(u'File') 110 110 title = _(u'Scan') 111 download_name = u'filename.jpg' 111 download_name = None 112 113 @property 114 def download_filename(self): 115 return u"%s.pdf" % self.context.document_id[:9] 112 116 113 117 @property … … 131 135 upload_button =_('Upload selected file') 132 136 delete_button = _('Delete') 137 138 @property 139 def download_filename(self): 140 return u"%s.pdf" % self.context.document_id[:9] 133 141 134 142 @property … … 175 183 """ 176 184 grok.baseclass() 177 grok.name('none.jpg') 178 download_name = u'none.jpg' 185 download_name = None 186 187 @property 188 def download_filename(self): 189 return u"%s.pdf" % self.context.document_id[:9] 179 190 180 191 def render(self): … … 198 209 elif ext == '.tif': 199 210 self.response.setHeader('Content-Type', 'image/tiff') 211 if self.download_filename: 212 self.response.setHeader('Content-Disposition', 213 'attachment; filename="%s' % self.download_filename) 200 214 return image -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/templates/filedisplay.pt
r12242 r12444 5 5 <td> 6 6 <a tal:attributes="href python: view.url(context, viewlet.download_name)" 7 tal:content="viewlet/download_ name"7 tal:content="viewlet/download_filename" 8 8 target="image"> 9 9 LINK -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/templates/fileupload.pt
r11949 r12444 7 7 <tal:file tal:condition="viewlet/file_exists"> 8 8 <a tal:attributes="href python: view.url(context, viewlet.download_name)" 9 tal:content="viewlet/ title"9 tal:content="viewlet/download_filename" 10 10 target="image"> 11 11 LINK -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/fileviewlets.py
r12408 r12444 97 97 class SampleScanEditUpload(SampleScanManageUpload): 98 98 """Scan upload viewlet for customer. 99 100 If a user has both permissions, waeup.manageCustomer and 101 waeup.handleCustomer, the upload viewlet appears twice. 99 102 """ 100 103 grok.view(DocumentEditFormPage) … … 121 124 grok.require('waeup.viewCustomer') 122 125 download_name = u'sample' 126 123 127 124 128 class SampleScanPDFSlip(SampleScanDisplay): … … 166 170 download_name = u'sample.pdf' 167 171 172 168 173 class PDFScanSlip(PDFScanDisplay): 169 174 grok.view(PDFDocumentSlipPage) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12388 r12444 1104 1104 name='upload_pdfscanmanageupload').click() 1105 1105 self.assertTrue( 1106 'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf"> PDF File</a>'1107 % docidin self.browser.contents)1106 'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">%s.pdf</a>' 1107 % (docid, docid[:9]) in self.browser.contents) 1108 1108 # Browsing the link shows a real pdf 1109 1109 self.browser.open('sample.pdf') -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py
r12442 r12444 146 146 form_fields_interface = IPDFDocument 147 147 148 filenames = (' scan.pdf',)148 filenames = ('file.pdf',) 149 149 150 150 PDFDocument = attrs_to_fields(PDFDocument) -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/fileviewlets.py
r12243 r12444 40 40 title = _(u'PDF File') 41 41 mus = 1024 * 200 42 download_name = u' sample.pdf'42 download_name = u'file.pdf' 43 43 tab_redirect = '#tab2' 44 44 … … 53 53 label = _(u'PDF Scan') 54 54 title = _(u'PDF Scan') 55 download_name = u' sample.pdf'55 download_name = u'file.pdf' 56 56 57 57 … … 59 59 """Scan document. 60 60 """ 61 ##: Needs to be protected if not published 62 grok.name('sample.pdf') 61 grok.name('file.pdf') 63 62 grok.context(PDFDocument) 64 63 grok.require('waeup.Public') 65 download_name = u' sample.pdf'64 download_name = u'file.pdf' 66 65 67 66 def update(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_browser.py
r12442 r12444 148 148 name='upload_pdfscanmanageupload').click() 149 149 self.assertTrue( 150 'href="http://localhost/app/documents/DOC1/ sample.pdf">PDF File</a>'150 'href="http://localhost/app/documents/DOC1/file.pdf">DOC1.pdf</a>' 151 151 in self.browser.contents) 152 152 # The file can be found in the file system 153 153 file = getUtility(IExtFileStore).getFileByContext( 154 document, attr=' sample.pdf')154 document, attr='file.pdf') 155 155 file_content = file.read() 156 156 pdf.seek(0) … … 159 159 # Browsing the link shows a real pdf only if the document 160 160 # has been published 161 self.browser.getLink(" PDF File").click()161 self.browser.getLink("DOC1.pdf").click() 162 162 self.assertTrue( 163 163 'The document requested has not yet been published' 164 164 in self.browser.contents) 165 165 IWorkflowState(document).setState(PUBLISHED) 166 self.browser.open(self.container_path + '/DOC1/ sample.pdf')166 self.browser.open(self.container_path + '/DOC1/file.pdf') 167 167 self.assertEqual( 168 168 self.browser.headers['content-type'], 'application/pdf') 169 # The name of the downloaded file will be different 170 self.assertEqual( 171 self.browser.headers['Content-Disposition'], 172 'attachment; filename="DOC1.pdf') 169 173 170 174 # Transitions can be performed … … 186 190 # File has been removed too 187 191 file = getUtility(IExtFileStore).getFileByContext( 188 document, attr=' sample.pdf')192 document, attr='file.pdf') 189 193 self.assertTrue(file is None) 190 194 … … 204 208 % document.document_id in logcontent) 205 209 self.assertTrue( 206 'INFO - zope.mgr - documents.browser.DocumentManageFormPage - %s - uploaded: sample.pdf (my_sample_scan.pdf)'210 'INFO - zope.mgr - documents.browser.DocumentManageFormPage - %s - uploaded: file.pdf (my_sample_scan.pdf)' 207 211 % document.document_id in logcontent) 208 212 self.assertTrue(
Note: See TracChangeset for help on using the changeset viewer.