[12035] | 1 | ## $Id: fileviewlets.py 12224 2014-12-14 09:08:16Z henrik $ |
---|
[11971] | 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 | |
---|
[12223] | 22 | from waeup.ikoba.browser.fileviewlets import ( |
---|
| 23 | FileDisplay, FileUpload, Image) |
---|
| 24 | |
---|
[12224] | 25 | from waeup.ikoba.customers.interfaces import ICustomer |
---|
[12057] | 26 | |
---|
| 27 | from waeup.ikoba.customers.documents import ( |
---|
| 28 | CustomerSampleDocument, CustomerPDFDocument |
---|
| 29 | ) |
---|
[11971] | 30 | from waeup.ikoba.customers.browser import ( |
---|
| 31 | CustomerBaseDisplayFormPage, CustomerBaseManageFormPage, |
---|
[12035] | 32 | CustomerFilesUploadPage, |
---|
[12050] | 33 | DocumentDisplayFormPage, DocumentManageFormPage, DocumentEditFormPage, |
---|
[12062] | 34 | PDFDocumentSlipPage,) |
---|
[11971] | 35 | |
---|
| 36 | grok.templatedir('browser_templates') |
---|
| 37 | |
---|
[11988] | 38 | # File viewlets for customer base page |
---|
| 39 | |
---|
[11971] | 40 | class PassportDisplay(FileDisplay): |
---|
| 41 | """Passport display viewlet. |
---|
| 42 | """ |
---|
| 43 | grok.order(1) |
---|
| 44 | grok.context(ICustomer) |
---|
[11987] | 45 | grok.view(CustomerBaseDisplayFormPage) |
---|
[11971] | 46 | grok.require('waeup.viewCustomer') |
---|
| 47 | grok.template('imagedisplay') |
---|
| 48 | label = _(u'Passport Picture') |
---|
| 49 | download_name = u'passport.jpg' |
---|
| 50 | |
---|
[11985] | 51 | |
---|
[12038] | 52 | class PassportManageUpload(FileUpload): |
---|
[11971] | 53 | """Passport upload viewlet for officers. |
---|
| 54 | """ |
---|
| 55 | grok.order(1) |
---|
| 56 | grok.context(ICustomer) |
---|
[11987] | 57 | grok.view(CustomerBaseManageFormPage) |
---|
[11971] | 58 | grok.require('waeup.manageCustomer') |
---|
| 59 | grok.template('imageupload') |
---|
| 60 | label = _(u'Passport Picture (jpg only)') |
---|
| 61 | mus = 1024 * 50 |
---|
| 62 | download_name = u'passport.jpg' |
---|
| 63 | tab_redirect = '#tab2' |
---|
| 64 | |
---|
[11985] | 65 | |
---|
[12038] | 66 | class PassportEditUpload(PassportManageUpload): |
---|
[11971] | 67 | """Passport upload viewlet for customers. |
---|
| 68 | """ |
---|
| 69 | grok.view(CustomerFilesUploadPage) |
---|
| 70 | grok.require('waeup.uploadCustomerFile') |
---|
| 71 | |
---|
[11985] | 72 | |
---|
[11971] | 73 | class Passport(Image): |
---|
| 74 | """Renders jpeg passport picture. |
---|
| 75 | """ |
---|
| 76 | grok.name('passport.jpg') |
---|
| 77 | download_name = u'passport.jpg' |
---|
| 78 | grok.context(ICustomer) |
---|
[11988] | 79 | grok.require('waeup.viewCustomer') |
---|
| 80 | |
---|
| 81 | # File viewlets for customer documents |
---|
[12035] | 82 | |
---|
[12062] | 83 | class SampleScanManageUpload(FileUpload): |
---|
[12038] | 84 | """Scan upload viewlet for officers. |
---|
[12035] | 85 | """ |
---|
| 86 | grok.order(1) |
---|
[12057] | 87 | grok.context(CustomerSampleDocument) |
---|
[12035] | 88 | grok.view(DocumentManageFormPage) |
---|
| 89 | grok.require('waeup.manageCustomer') |
---|
[12057] | 90 | label = _(u'Sample Scan') |
---|
| 91 | title = _(u'Sample Scan') |
---|
[12035] | 92 | mus = 1024 * 50 |
---|
[12057] | 93 | download_name = u'sample' |
---|
[12035] | 94 | tab_redirect = '#tab2' |
---|
| 95 | |
---|
[12036] | 96 | |
---|
[12062] | 97 | class SampleScanEditUpload(SampleScanManageUpload): |
---|
[12038] | 98 | """Scan upload viewlet for customer. |
---|
[12036] | 99 | """ |
---|
| 100 | grok.view(DocumentEditFormPage) |
---|
| 101 | grok.require('waeup.handleCustomer') |
---|
| 102 | |
---|
| 103 | |
---|
[12062] | 104 | class SampleScanDisplay(FileDisplay): |
---|
[12038] | 105 | """Scan display viewlet. |
---|
[12035] | 106 | """ |
---|
| 107 | grok.order(1) |
---|
[12057] | 108 | grok.context(CustomerSampleDocument) |
---|
[12035] | 109 | grok.require('waeup.viewCustomer') |
---|
| 110 | grok.view(DocumentDisplayFormPage) |
---|
[12057] | 111 | label = _(u'Sample Scan') |
---|
| 112 | title = _(u'Sample Scan') |
---|
| 113 | download_name = u'sample' |
---|
[12035] | 114 | |
---|
[12036] | 115 | |
---|
[12057] | 116 | class SampleScanImage(Image): |
---|
[12038] | 117 | """Scan document. |
---|
[12035] | 118 | """ |
---|
[12057] | 119 | grok.name('sample') |
---|
| 120 | grok.context(CustomerSampleDocument) |
---|
[12035] | 121 | grok.require('waeup.viewCustomer') |
---|
[12057] | 122 | download_name = u'sample' |
---|
| 123 | |
---|
[12062] | 124 | class SampleScanPDFSlip(SampleScanDisplay): |
---|
| 125 | grok.view(PDFDocumentSlipPage) |
---|
[12057] | 126 | |
---|
[12062] | 127 | |
---|
| 128 | class PDFScanManageUpload(FileUpload): |
---|
[12057] | 129 | """Scan upload viewlet for officers. |
---|
| 130 | """ |
---|
| 131 | grok.view(DocumentManageFormPage) |
---|
| 132 | grok.context(CustomerPDFDocument) |
---|
| 133 | grok.require('waeup.manageCustomer') |
---|
| 134 | label = _(u'PDF File') |
---|
| 135 | title = _(u'PDF File') |
---|
| 136 | mus = 1024 * 200 |
---|
[12058] | 137 | download_name = u'sample.pdf' |
---|
[12057] | 138 | tab_redirect = '#tab2' |
---|
| 139 | |
---|
| 140 | |
---|
[12062] | 141 | class PDFScanEditUpload(PDFScanManageUpload): |
---|
[12057] | 142 | """Scan upload viewlet for customer. |
---|
| 143 | """ |
---|
| 144 | grok.view(DocumentEditFormPage) |
---|
| 145 | grok.require('waeup.handleCustomer') |
---|
| 146 | |
---|
| 147 | |
---|
[12062] | 148 | class PDFScanDisplay(FileDisplay): |
---|
[12057] | 149 | """Scan display viewlet. |
---|
| 150 | """ |
---|
| 151 | grok.order(1) |
---|
| 152 | grok.context(CustomerPDFDocument) |
---|
| 153 | grok.require('waeup.viewCustomer') |
---|
| 154 | grok.view(DocumentDisplayFormPage) |
---|
| 155 | label = _(u'PDF Scan') |
---|
| 156 | title = _(u'PDF Scan') |
---|
[12058] | 157 | download_name = u'sample.pdf' |
---|
[12057] | 158 | |
---|
| 159 | |
---|
| 160 | class PDFScanImage(Image): |
---|
| 161 | """Scan document. |
---|
| 162 | """ |
---|
[12058] | 163 | grok.name('sample.pdf') |
---|
[12057] | 164 | grok.context(CustomerPDFDocument) |
---|
| 165 | grok.require('waeup.viewCustomer') |
---|
[12058] | 166 | download_name = u'sample.pdf' |
---|
[12062] | 167 | |
---|
| 168 | class PDFScanSlip(PDFScanDisplay): |
---|
| 169 | grok.view(PDFDocumentSlipPage) |
---|