[12355] | 1 | ## $Id: fileviewlets.py 12347 2014-12-31 08:18:54Z 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 | |
---|
| 19 | import grok |
---|
| 20 | from waeup.ikoba.interfaces import MessageFactory as _ |
---|
| 21 | |
---|
| 22 | from waeup.ikoba.browser.fileviewlets import ( |
---|
| 23 | FileDisplay, FileUpload, Image) |
---|
| 24 | |
---|
| 25 | from ikobacustom.skeleton.customers.documents import SkeletonCustomerDocument |
---|
| 26 | |
---|
| 27 | from waeup.ikoba.customers.browser import ( |
---|
| 28 | DocumentDisplayFormPage, |
---|
| 29 | DocumentManageFormPage, |
---|
| 30 | DocumentEditFormPage, |
---|
| 31 | PDFDocumentSlipPage,) |
---|
| 32 | |
---|
| 33 | grok.templatedir('browser_templates') |
---|
| 34 | |
---|
| 35 | # File viewlets for customer documents |
---|
| 36 | |
---|
| 37 | class SampleScanManageUpload(FileUpload): |
---|
| 38 | """Scan upload viewlet for officers. |
---|
| 39 | """ |
---|
| 40 | grok.order(1) |
---|
| 41 | grok.context(SkeletonCustomerDocument) |
---|
| 42 | grok.view(DocumentManageFormPage) |
---|
| 43 | grok.require('waeup.manageCustomer') |
---|
| 44 | label = _(u'Sample Scan') |
---|
| 45 | title = _(u'Sample Scan') |
---|
| 46 | mus = 1024 * 50 |
---|
| 47 | download_name = u'sample' |
---|
| 48 | tab_redirect = '#tab2' |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | class SampleScanEditUpload(SampleScanManageUpload): |
---|
| 52 | """Scan upload viewlet for customer. |
---|
| 53 | """ |
---|
| 54 | grok.view(DocumentEditFormPage) |
---|
| 55 | grok.require('waeup.handleCustomer') |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | class SampleScanDisplay(FileDisplay): |
---|
| 59 | """Scan display viewlet. |
---|
| 60 | """ |
---|
| 61 | grok.order(1) |
---|
| 62 | grok.context(SkeletonCustomerDocument) |
---|
| 63 | grok.require('waeup.viewCustomer') |
---|
| 64 | grok.view(DocumentDisplayFormPage) |
---|
| 65 | label = _(u'Sample Scan') |
---|
| 66 | title = _(u'Sample Scan') |
---|
| 67 | download_name = u'sample' |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | class SampleScanImage(Image): |
---|
| 71 | """Scan document. |
---|
| 72 | """ |
---|
| 73 | grok.name('sample') |
---|
| 74 | grok.context(SkeletonCustomerDocument) |
---|
| 75 | grok.require('waeup.viewCustomer') |
---|
| 76 | download_name = u'sample' |
---|
| 77 | |
---|
| 78 | class SampleScanPDFSlip(SampleScanDisplay): |
---|
| 79 | grok.view(PDFDocumentSlipPage) |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | class PDFScanManageUpload(FileUpload): |
---|
| 83 | """Scan upload viewlet for officers. |
---|
| 84 | """ |
---|
| 85 | grok.view(DocumentManageFormPage) |
---|
| 86 | grok.context(SkeletonCustomerDocument) |
---|
| 87 | grok.require('waeup.manageCustomer') |
---|
| 88 | label = _(u'PDF File') |
---|
| 89 | title = _(u'PDF File') |
---|
| 90 | mus = 1024 * 200 |
---|
| 91 | download_name = u'sample.pdf' |
---|
| 92 | tab_redirect = '#tab2' |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | class PDFScanEditUpload(PDFScanManageUpload): |
---|
| 96 | """Scan upload viewlet for customer. |
---|
| 97 | """ |
---|
| 98 | grok.view(DocumentEditFormPage) |
---|
| 99 | grok.require('waeup.handleCustomer') |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | class PDFScanDisplay(FileDisplay): |
---|
| 103 | """Scan display viewlet. |
---|
| 104 | """ |
---|
| 105 | grok.order(1) |
---|
| 106 | grok.context(SkeletonCustomerDocument) |
---|
| 107 | grok.require('waeup.viewCustomer') |
---|
| 108 | grok.view(DocumentDisplayFormPage) |
---|
| 109 | label = _(u'PDF Scan') |
---|
| 110 | title = _(u'PDF Scan') |
---|
| 111 | download_name = u'sample.pdf' |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | class PDFScanImage(Image): |
---|
| 115 | """Scan document. |
---|
| 116 | """ |
---|
| 117 | grok.name('sample.pdf') |
---|
| 118 | grok.context(SkeletonCustomerDocument) |
---|
| 119 | grok.require('waeup.viewCustomer') |
---|
| 120 | download_name = u'sample.pdf' |
---|
| 121 | |
---|
| 122 | class PDFScanSlip(PDFScanDisplay): |
---|
| 123 | grok.view(PDFDocumentSlipPage) |
---|