source: main/waeup.ikoba/trunk/src/waeup/ikoba/documents/fileviewlets.py @ 12444

Last change on this file since 12444 was 12444, checked in by Henrik Bettermann, 10 years ago

We need to provide unique filenames. Let's use the document id for the filename and not the download_name of the respective viewlet.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1## $Id: fileviewlets.py 12444 2015-01-11 22:43:35Z henrik $
2##
3## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18
19import grok
20from waeup.ikoba.interfaces import MessageFactory as _
21from waeup.ikoba.interfaces import PUBLISHED
22from waeup.ikoba.browser.layout import UtilityView
23from waeup.ikoba.browser.fileviewlets import (
24    FileDisplay, FileUpload, Image)
25
26from waeup.ikoba.documents.document import PDFDocument
27from waeup.ikoba.documents.browser import (
28    DocumentManageFormPage, DocumentDisplayFormPage)
29
30
31# File viewlets for documents
32
33class PDFScanManageUpload(FileUpload):
34    """Scan upload viewlet for officers.
35    """
36    grok.view(DocumentManageFormPage)
37    grok.context(PDFDocument)
38    grok.require('waeup.manageDocuments')
39    label = _(u'PDF File')
40    title = _(u'PDF File')
41    mus = 1024 * 200
42    download_name = u'file.pdf'
43    tab_redirect = '#tab2'
44
45
46class PDFScanDisplay(FileDisplay):
47    """Scan display viewlet.
48    """
49    grok.order(1)
50    grok.context(PDFDocument)
51    grok.require('waeup.viewDocuments')
52    grok.view(DocumentDisplayFormPage)
53    label = _(u'PDF Scan')
54    title = _(u'PDF Scan')
55    download_name = u'file.pdf'
56
57
58class PDFScanImage(UtilityView, Image):
59    """Scan document.
60    """
61    grok.name('file.pdf')
62    grok.context(PDFDocument)
63    grok.require('waeup.Public')
64    download_name = u'file.pdf'
65
66    def update(self):
67        if self.context.state != PUBLISHED:
68            self.flash(_('The document requested has not yet been published.'),
69                type="warning")
70            self.redirect(self.application_url())
71        return
Note: See TracBrowser for help on using the repository browser.