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

Show file size of pdf documents in the documents section.

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

Legend:

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

    r13147 r13263  
    1818
    1919import grok
     20from zope.component import getUtility
     21from waeup.kofa.interfaces import IExtFileStore
    2022from waeup.kofa.interfaces import MessageFactory as _
    2123from waeup.kofa.browser.layout import UtilityView
    2224from waeup.kofa.browser.fileviewlets import (
    2325    FileDisplay, FileUpload, Image)
     26from waeup.kofa.utils.helpers import file_size
    2427
    2528from waeup.kofa.documents.document import PDFDocument
     
    4649    @property
    4750    def download_filename(self):
    48         return u"%s.pdf" % self.context.document_id
     51        file = getUtility(IExtFileStore).getFileByContext(
     52            self.context, attr=self.download_name)
     53        fs = file_size(file)/1024.0
     54        return u"%s.pdf (%.1f kB)" % (self.context.document_id, fs)
    4955
    5056
     
    6268    @property
    6369    def download_filename(self):
    64         return u"%s.pdf" % self.context.document_id
     70        file = getUtility(IExtFileStore).getFileByContext(
     71            self.context, attr=self.download_name)
     72        fs = file_size(file)/1024.0
     73        return u"%s.pdf (%.1f kB)" % (self.context.document_id, fs)
    6574
    6675
  • main/waeup.kofa/trunk/src/waeup/kofa/documents/tests/test_browser.py

    r13138 r13263  
    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.