[12373] | 1 | ## $Id: fileviewlets.py 12534 2015-02-01 07:11:07Z henrik $ |
---|
[12355] | 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 _ |
---|
[12534] | 21 | from waeup.ikoba.customers.interfaces import ICustomer |
---|
[12355] | 22 | from waeup.ikoba.browser.fileviewlets import ( |
---|
| 23 | FileDisplay, FileUpload, Image) |
---|
| 24 | |
---|
[12384] | 25 | from ikobacustom.pcn.customers.documents import ( |
---|
| 26 | PCNCustomerJPGDocument, PCNCustomerPDFDocument) |
---|
[12355] | 27 | |
---|
| 28 | from waeup.ikoba.customers.browser import ( |
---|
[12534] | 29 | CustomerBaseDisplayFormPage, |
---|
| 30 | CustomerBaseManageFormPage, |
---|
| 31 | CustomerFilesUploadPage, |
---|
[12355] | 32 | DocumentDisplayFormPage, |
---|
| 33 | DocumentManageFormPage, |
---|
| 34 | DocumentEditFormPage, |
---|
[12534] | 35 | PDFDocumentSlipPage) |
---|
[12355] | 36 | |
---|
| 37 | grok.templatedir('browser_templates') |
---|
| 38 | |
---|
[12534] | 39 | # File viewlets for customer base page |
---|
| 40 | |
---|
| 41 | class BirthCertificateDisplay(FileDisplay): |
---|
| 42 | """Birth certificate display viewlet. |
---|
| 43 | """ |
---|
| 44 | grok.order(2) |
---|
| 45 | grok.context(ICustomer) |
---|
| 46 | grok.view(CustomerBaseDisplayFormPage) |
---|
| 47 | grok.require('waeup.viewCustomer') |
---|
| 48 | label = _(u'Birth Certificate') |
---|
| 49 | download_name = u'birth_certificate.pdf' |
---|
| 50 | download_filename = u'birth_certificate.pdf' |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | class BirthCertificateManageUpload(FileUpload): |
---|
| 54 | """Birth Certificate upload viewlet for officers. |
---|
| 55 | """ |
---|
| 56 | grok.order(2) |
---|
| 57 | grok.context(ICustomer) |
---|
| 58 | grok.view(CustomerBaseManageFormPage) |
---|
| 59 | grok.require('waeup.manageCustomer') |
---|
| 60 | label = _(u'Birth Certificate (pdf only)') |
---|
| 61 | mus = 1024 * 200 |
---|
| 62 | download_name = u'birth_certificate.pdf' |
---|
| 63 | download_filename = u'birth_certificate.pdf' |
---|
| 64 | tab_redirect = '#tab2' |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | class BirthCertificateEditUpload(BirthCertificateManageUpload): |
---|
| 68 | """Birth certificate upload viewlet for customers. |
---|
| 69 | """ |
---|
| 70 | grok.view(CustomerFilesUploadPage) |
---|
| 71 | grok.require('waeup.handleCustomer') |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | class BirthCertificate(Image): |
---|
| 75 | """Renders pdf. |
---|
| 76 | """ |
---|
| 77 | grok.name('birth_certificate.pdf') |
---|
| 78 | download_name = u'birth_certificate.pdf' |
---|
| 79 | grok.context(ICustomer) |
---|
| 80 | grok.require('waeup.viewCustomer') |
---|
| 81 | download_filename = u'birth_certificate.pdf' |
---|
| 82 | |
---|
[12355] | 83 | # File viewlets for customer documents |
---|
| 84 | |
---|
[12384] | 85 | class JPGScanManageUpload(FileUpload): |
---|
[12355] | 86 | """Scan upload viewlet for officers. |
---|
| 87 | """ |
---|
| 88 | grok.order(1) |
---|
[12384] | 89 | grok.context(PCNCustomerJPGDocument) |
---|
[12355] | 90 | grok.view(DocumentManageFormPage) |
---|
| 91 | grok.require('waeup.manageCustomer') |
---|
| 92 | label = _(u'Sample Scan') |
---|
| 93 | title = _(u'Sample Scan') |
---|
[12403] | 94 | mus = 1024 * 200 |
---|
[12384] | 95 | download_name = u'scan.jpg' |
---|
[12355] | 96 | tab_redirect = '#tab2' |
---|
| 97 | |
---|
[12460] | 98 | @property |
---|
| 99 | def download_filename(self): |
---|
| 100 | return u"%s.jpg" % self.context.document_id[:9] |
---|
[12355] | 101 | |
---|
[12460] | 102 | |
---|
[12384] | 103 | class JPGScanEditUpload(JPGScanManageUpload): |
---|
[12355] | 104 | """Scan upload viewlet for customer. |
---|
| 105 | """ |
---|
| 106 | grok.view(DocumentEditFormPage) |
---|
| 107 | grok.require('waeup.handleCustomer') |
---|
| 108 | |
---|
| 109 | |
---|
[12384] | 110 | class JPGScanDisplay(FileDisplay): |
---|
[12355] | 111 | """Scan display viewlet. |
---|
| 112 | """ |
---|
| 113 | grok.order(1) |
---|
[12384] | 114 | grok.context(PCNCustomerJPGDocument) |
---|
[12355] | 115 | grok.require('waeup.viewCustomer') |
---|
| 116 | grok.view(DocumentDisplayFormPage) |
---|
| 117 | label = _(u'Sample Scan') |
---|
| 118 | title = _(u'Sample Scan') |
---|
[12384] | 119 | download_name = u'scan.jpg' |
---|
[12355] | 120 | |
---|
[12460] | 121 | @property |
---|
| 122 | def download_filename(self): |
---|
| 123 | return u"%s.jpg" % self.context.document_id[:9] |
---|
[12355] | 124 | |
---|
[12460] | 125 | |
---|
[12384] | 126 | class JPGScanImage(Image): |
---|
[12355] | 127 | """Scan document. |
---|
| 128 | """ |
---|
[12384] | 129 | grok.name('scan.jpg') |
---|
| 130 | grok.context(PCNCustomerJPGDocument) |
---|
[12355] | 131 | grok.require('waeup.viewCustomer') |
---|
[12384] | 132 | download_name = u'scan.jpg' |
---|
[12355] | 133 | |
---|
[12460] | 134 | @property |
---|
| 135 | def download_filename(self): |
---|
| 136 | return u"%s.jpg" % self.context.document_id[:9] |
---|
| 137 | |
---|
[12384] | 138 | class JPGScanPDFSlip(JPGScanDisplay): |
---|
[12355] | 139 | grok.view(PDFDocumentSlipPage) |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | class PDFScanManageUpload(FileUpload): |
---|
| 143 | """Scan upload viewlet for officers. |
---|
| 144 | """ |
---|
| 145 | grok.view(DocumentManageFormPage) |
---|
[12384] | 146 | grok.context(PCNCustomerPDFDocument) |
---|
[12355] | 147 | grok.require('waeup.manageCustomer') |
---|
| 148 | label = _(u'PDF File') |
---|
| 149 | title = _(u'PDF File') |
---|
[12403] | 150 | mus = 1024 * 1000 |
---|
[12384] | 151 | download_name = u'scan.pdf' |
---|
[12355] | 152 | tab_redirect = '#tab2' |
---|
| 153 | |
---|
[12460] | 154 | @property |
---|
| 155 | def download_filename(self): |
---|
| 156 | return u"%s.pdf" % self.context.document_id[:9] |
---|
[12355] | 157 | |
---|
[12460] | 158 | |
---|
[12355] | 159 | class PDFScanEditUpload(PDFScanManageUpload): |
---|
| 160 | """Scan upload viewlet for customer. |
---|
| 161 | """ |
---|
| 162 | grok.view(DocumentEditFormPage) |
---|
| 163 | grok.require('waeup.handleCustomer') |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | class PDFScanDisplay(FileDisplay): |
---|
| 167 | """Scan display viewlet. |
---|
| 168 | """ |
---|
| 169 | grok.order(1) |
---|
[12384] | 170 | grok.context(PCNCustomerPDFDocument) |
---|
[12355] | 171 | grok.require('waeup.viewCustomer') |
---|
| 172 | grok.view(DocumentDisplayFormPage) |
---|
| 173 | label = _(u'PDF Scan') |
---|
| 174 | title = _(u'PDF Scan') |
---|
[12384] | 175 | download_name = u'scan.pdf' |
---|
[12355] | 176 | |
---|
[12460] | 177 | @property |
---|
| 178 | def download_filename(self): |
---|
| 179 | return u"%s.pdf" % self.context.document_id[:9] |
---|
[12355] | 180 | |
---|
[12460] | 181 | |
---|
[12355] | 182 | class PDFScanImage(Image): |
---|
| 183 | """Scan document. |
---|
| 184 | """ |
---|
[12384] | 185 | grok.name('scan.pdf') |
---|
| 186 | grok.context(PCNCustomerPDFDocument) |
---|
[12355] | 187 | grok.require('waeup.viewCustomer') |
---|
[12384] | 188 | download_name = u'scan.pdf' |
---|
[12355] | 189 | |
---|
[12460] | 190 | @property |
---|
| 191 | def download_filename(self): |
---|
| 192 | return u"%s" % self.context.document_id[:9] |
---|
| 193 | |
---|
[12355] | 194 | class PDFScanSlip(PDFScanDisplay): |
---|
| 195 | grok.view(PDFDocumentSlipPage) |
---|