Changeset 12447 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 12 Jan 2015, 09:24:58 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/filedisplay.pt
r11254 r12447 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.kofa/trunk/src/waeup/kofa/browser/templates/fileupload.pt
r11569 r12447 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.kofa/trunk/src/waeup/kofa/documents/fileviewlets.py
r12438 r12447 44 44 tab_redirect = '#tab2' 45 45 46 @property 47 def download_filename(self): 48 return u"%s.pdf" % self.context.document_id 49 46 50 47 51 class PDFScanDisplay(FileDisplay): … … 56 60 download_name = u'sample.pdf' 57 61 62 @property 63 def download_filename(self): 64 return u"%s.pdf" % self.context.document_id 65 58 66 59 67 class PDFScanImage(UtilityView, Image): … … 66 74 download_name = u'sample.pdf' 67 75 76 @property 77 def download_filename(self): 78 return self.context.document_id 79 68 80 def update(self): 69 81 if self.context.state != PUBLISHED: -
main/waeup.kofa/trunk/src/waeup/kofa/documents/tests/test_browser.py
r12441 r12447 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/sample.pdf">DOC1.pdf</a>' 151 151 in self.browser.contents) 152 152 # The file can be found in the file system … … 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' … … 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 -
main/waeup.kofa/trunk/src/waeup/kofa/students/fileviewlets.py
r12438 r12447 120 120 label = _(u'File') 121 121 title = _(u'Scan') 122 download_name = u'filename.jpg' 122 123 @property 124 def download_filename(self): 125 return self.download_name 123 126 124 127 @property … … 241 244 """ 242 245 grok.baseclass() 243 grok.name('none.jpg')244 246 grok.context(IStudent) 245 247 grok.require('waeup.viewStudent') 246 download_name = u'none.jpg' 248 249 @property 250 def download_filename(self): 251 return self.download_name 247 252 248 253 def render(self): … … 262 267 elif ext == '.png': 263 268 self.response.setHeader('Content-Type', 'image/png') 269 elif ext == '.tif': 270 self.response.setHeader('Content-Type', 'image/tiff') 264 271 elif ext == '.pdf': 265 272 self.response.setHeader('Content-Type', 'application/pdf') 266 elif ext == '.tif':267 self.response.setHeader('Content-Type', 'image/tiff')273 self.response.setHeader('Content-Disposition', 274 'attachment; filename="%s.pdf' % self.download_filename) 268 275 return image 269 276
Note: See TracChangeset for help on using the changeset viewer.