Changeset 13264 for main/waeup.ikoba


Ignore:
Timestamp:
17 Sep 2015, 08:33:26 (9 years ago)
Author:
Henrik Bettermann
Message:

Show file size of pdf documents in the documents section.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/documents
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/fileviewlets.py

    r12458 r13264  
    1818
    1919import grok
     20from zope.component import getUtility
     21from waeup.ikoba.interfaces import IExtFileStore
    2022from waeup.ikoba.interfaces import MessageFactory as _
    2123from waeup.ikoba.interfaces import PUBLISHED
     
    2325from waeup.ikoba.browser.fileviewlets import (
    2426    FileDisplay, FileUpload, Image)
     27from waeup.ikoba.utils.helpers import file_size
    2528
    2629from waeup.ikoba.documents.document import PDFDocument
     
    4548    @property
    4649    def download_filename(self):
    47         return u"%s.pdf" % self.context.document_id
     50        file = getUtility(IExtFileStore).getFileByContext(
     51            self.context, attr=self.download_name)
     52        fs = file_size(file)/1024.0
     53        return u"%s.pdf (%.1f kB)" % (self.context.document_id, fs)
    4854
    4955
     
    6167    @property
    6268    def download_filename(self):
    63         return u"%s.pdf" % self.context.document_id
     69        file = getUtility(IExtFileStore).getFileByContext(
     70            self.context, attr=self.download_name)
     71        fs = file_size(file)/1024.0
     72        return u"%s.pdf (%.1f kB)" % (self.context.document_id, fs)
    6473
    6574
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_browser.py

    r13139 r13264  
    147147        self.browser.getControl(
    148148            name='upload_pdfscanmanageupload').click()
    149         self.assertTrue(
    150             'href="http://localhost/app/documents/DOC1/file.pdf">DOC1.pdf</a>'
     149        # The file size is shown
     150        self.assertTrue(
     151            'href="http://localhost/app/documents/DOC1/file.pdf">DOC1.pdf (23.7 kB)</a>'
     152            in self.browser.contents)
     153        # Also on display page the file size is displayed.
     154        self.browser.open(self.container_path + '/DOC1')
     155        self.assertTrue(
     156            'href="http://localhost/app/documents/DOC1/file.pdf">DOC1.pdf (23.7 kB)</a>'
    151157            in self.browser.contents)
    152158        # The file can be found in the file system
Note: See TracChangeset for help on using the changeset viewer.