[12438] | 1 | ## $Id: fileviewlets.py 13134 2015-07-03 10:19:55Z 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 | |
---|
| 19 | import grok |
---|
| 20 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
| 21 | from waeup.kofa.browser.layout import UtilityView |
---|
[12448] | 22 | from waeup.kofa.browser.fileviewlets import ( |
---|
[12437] | 23 | FileDisplay, FileUpload, Image) |
---|
| 24 | |
---|
| 25 | from waeup.kofa.documents.document import PDFDocument |
---|
| 26 | from waeup.kofa.documents.browser import ( |
---|
| 27 | DocumentManageFormPage, DocumentDisplayFormPage) |
---|
| 28 | |
---|
| 29 | from waeup.kofa.documents.workflow import PUBLISHED |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | # File viewlets for documents |
---|
| 33 | |
---|
| 34 | class 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 |
---|
[12456] | 43 | download_name = u'file.pdf' |
---|
[12437] | 44 | tab_redirect = '#tab2' |
---|
| 45 | |
---|
[12447] | 46 | @property |
---|
| 47 | def download_filename(self): |
---|
| 48 | return u"%s.pdf" % self.context.document_id |
---|
[12437] | 49 | |
---|
[12447] | 50 | |
---|
[12437] | 51 | class 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') |
---|
[12456] | 60 | download_name = u'file.pdf' |
---|
[12437] | 61 | |
---|
[12447] | 62 | @property |
---|
| 63 | def download_filename(self): |
---|
| 64 | return u"%s.pdf" % self.context.document_id |
---|
[12437] | 65 | |
---|
[12447] | 66 | |
---|
[12437] | 67 | class PDFScanImage(UtilityView, Image): |
---|
| 68 | """Scan document. |
---|
| 69 | """ |
---|
[12456] | 70 | grok.name('file.pdf') |
---|
[12437] | 71 | grok.context(PDFDocument) |
---|
| 72 | grok.require('waeup.Public') |
---|
[12456] | 73 | download_name = u'file.pdf' |
---|
[12437] | 74 | |
---|
[12447] | 75 | @property |
---|
| 76 | def download_filename(self): |
---|
| 77 | return self.context.document_id |
---|
| 78 | |
---|
[12437] | 79 | def update(self): |
---|
| 80 | if self.context.state != PUBLISHED: |
---|
| 81 | self.flash(_('The document requested has not yet been published.'), |
---|
| 82 | type="warning") |
---|
| 83 | self.redirect(self.application_url()) |
---|
| 84 | return |
---|