source: main/waeup.kofa/trunk/src/waeup/kofa/documents/fileviewlets.py @ 12461

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

Omit document_id on manage pages. Rename sample.pdf.

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1## $Id: fileviewlets.py 12456 2015-01-13 06:23:01Z 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.kofa.interfaces import MessageFactory as _
21from waeup.kofa.browser.layout import UtilityView
22from waeup.kofa.browser.fileviewlets import (
23    FileDisplay, FileUpload, Image)
24
25from waeup.kofa.documents.document import PDFDocument
26from waeup.kofa.documents.browser import (
27    DocumentManageFormPage, DocumentDisplayFormPage)
28
29from waeup.kofa.documents.workflow import PUBLISHED
30
31
32# File viewlets for documents
33
34class PDFScanManageUpload(FileUpload):
35    """Scan upload viewlet for officers.
36    """
37    grok.view(DocumentManageFormPage)
38    grok.context(PDFDocument)
39    grok.require('waeup.manageDocuments')
40    label = _(u'PDF File')
41    title = _(u'PDF File')
42    mus = 1024 * 200
43    download_name = u'file.pdf'
44    tab_redirect = '#tab2'
45
46    @property
47    def download_filename(self):
48        return u"%s.pdf" % self.context.document_id
49
50
51class PDFScanDisplay(FileDisplay):
52    """Scan display viewlet.
53    """
54    grok.order(1)
55    grok.context(PDFDocument)
56    grok.require('waeup.viewDocuments')
57    grok.view(DocumentDisplayFormPage)
58    label = _(u'PDF Scan')
59    title = _(u'PDF Scan')
60    download_name = u'file.pdf'
61
62    @property
63    def download_filename(self):
64        return u"%s.pdf" % self.context.document_id
65
66
67class PDFScanImage(UtilityView, Image):
68    """Scan document.
69    """
70    ##: Needs to be protected if not published
71    grok.name('file.pdf')
72    grok.context(PDFDocument)
73    grok.require('waeup.Public')
74    download_name = u'file.pdf'
75
76    @property
77    def download_filename(self):
78        return self.context.document_id
79
80    def update(self):
81        if self.context.state != PUBLISHED:
82            self.flash(_('The document requested has not yet been published.'),
83                type="warning")
84            self.redirect(self.application_url())
85        return
Note: See TracBrowser for help on using the repository browser.