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

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

Propset svn:keywords "Id"

  • Property svn:keywords set to Id
File size: 2.3 KB
RevLine 
[12438]1## $Id: fileviewlets.py 12438 2015-01-11 08:27:37Z henrik $
[12437]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.students.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'sample.pdf'
44    tab_redirect = '#tab2'
45
46
47class PDFScanDisplay(FileDisplay):
48    """Scan display viewlet.
49    """
50    grok.order(1)
51    grok.context(PDFDocument)
52    grok.require('waeup.viewDocuments')
53    grok.view(DocumentDisplayFormPage)
54    label = _(u'PDF Scan')
55    title = _(u'PDF Scan')
56    download_name = u'sample.pdf'
57
58
59class PDFScanImage(UtilityView, Image):
60    """Scan document.
61    """
62    ##: Needs to be protected if not published
63    grok.name('sample.pdf')
64    grok.context(PDFDocument)
65    grok.require('waeup.Public')
66    download_name = u'sample.pdf'
67
68    def update(self):
69        if self.context.state != PUBLISHED:
70            self.flash(_('The document requested has not yet been published.'),
71                type="warning")
72            self.redirect(self.application_url())
73        return
Note: See TracBrowser for help on using the repository browser.