source: main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/fileviewlets.py @ 12678

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

Add another file viewlet.

  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1## $Id: fileviewlets.py 12557 2015-02-03 17:38:21Z 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
19import grok
20from waeup.ikoba.interfaces import MessageFactory as _
21from waeup.ikoba.customers.interfaces import ICustomer
22from waeup.ikoba.browser.fileviewlets import (
23    FileDisplay, FileUpload, Image)
24
25from ikobacustom.pcn.customers.documents import (
26    PCNCustomerJPGDocument, PCNCustomerPDFDocument)
27
28from waeup.ikoba.customers.browser import (
29    CustomerBaseDisplayFormPage,
30    CustomerBaseManageFormPage,
31    CustomerFilesUploadPage,
32    DocumentDisplayFormPage,
33    DocumentManageFormPage,
34    DocumentEditFormPage,
35    PDFDocumentSlipPage)
36
37grok.templatedir('browser_templates')
38
39# File viewlets for customer base page
40
41class 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
53class 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
67class BirthCertificateEditUpload(BirthCertificateManageUpload):
68    """Birth certificate upload viewlet for customers.
69    """
70    grok.view(CustomerFilesUploadPage)
71    grok.require('waeup.handleCustomer')
72
73
74class 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
83class CertificatesDisplay(FileDisplay):
84    """Certificates display viewlet.
85    """
86    grok.order(2)
87    grok.context(ICustomer)
88    grok.view(CustomerBaseDisplayFormPage)
89    grok.require('waeup.viewCustomer')
90    label = _(u'Certificates/Credentials')
91    download_name = u'certificates.pdf'
92    download_filename = u'certificates.pdf'
93
94
95class CertificatesManageUpload(FileUpload):
96    """Certificates upload viewlet for officers.
97    """
98    grok.order(2)
99    grok.context(ICustomer)
100    grok.view(CustomerBaseManageFormPage)
101    grok.require('waeup.manageCustomer')
102    label = _(u'Certificates/Credentials (pdf only)')
103    mus = 1024 * 200
104    download_name = u'certificates.pdf'
105    download_filename = u'certificates.pdf'
106    tab_redirect = '#tab2'
107
108
109class CertificatesEditUpload(CertificatesManageUpload):
110    """Certificates upload viewlet for customers.
111    """
112    grok.view(CustomerFilesUploadPage)
113    grok.require('waeup.handleCustomer')
114
115
116class Certificates(Image):
117    """Renders pdf.
118    """
119    grok.name('certificates.pdf')
120    download_name = u'certificates.pdf'
121    grok.context(ICustomer)
122    grok.require('waeup.viewCustomer')
123    download_filename = u'certificates.pdf'
124
125# File viewlets for customer documents
126
127class JPGScanManageUpload(FileUpload):
128    """Scan upload viewlet for officers.
129    """
130    grok.order(1)
131    grok.context(PCNCustomerJPGDocument)
132    grok.view(DocumentManageFormPage)
133    grok.require('waeup.manageCustomer')
134    label = _(u'Sample Scan')
135    title = _(u'Sample Scan')
136    mus = 1024 * 200
137    download_name = u'scan.jpg'
138    tab_redirect = '#tab2'
139
140    @property
141    def download_filename(self):
142        return u"%s.jpg" % self.context.document_id[:9]
143
144
145class JPGScanEditUpload(JPGScanManageUpload):
146    """Scan upload viewlet for customer.
147    """
148    grok.view(DocumentEditFormPage)
149    grok.require('waeup.handleCustomer')
150
151
152class JPGScanDisplay(FileDisplay):
153    """Scan display viewlet.
154    """
155    grok.order(1)
156    grok.context(PCNCustomerJPGDocument)
157    grok.require('waeup.viewCustomer')
158    grok.view(DocumentDisplayFormPage)
159    label = _(u'Sample Scan')
160    title = _(u'Sample Scan')
161    download_name = u'scan.jpg'
162
163    @property
164    def download_filename(self):
165        return u"%s.jpg" % self.context.document_id[:9]
166
167
168class JPGScanImage(Image):
169    """Scan document.
170    """
171    grok.name('scan.jpg')
172    grok.context(PCNCustomerJPGDocument)
173    grok.require('waeup.viewCustomer')
174    download_name = u'scan.jpg'
175
176    @property
177    def download_filename(self):
178        return u"%s.jpg" % self.context.document_id[:9]
179
180class JPGScanPDFSlip(JPGScanDisplay):
181    grok.view(PDFDocumentSlipPage)
182
183
184class PDFScanManageUpload(FileUpload):
185    """Scan upload viewlet for officers.
186    """
187    grok.view(DocumentManageFormPage)
188    grok.context(PCNCustomerPDFDocument)
189    grok.require('waeup.manageCustomer')
190    label = _(u'PDF File')
191    title = _(u'PDF File')
192    mus = 1024 * 1000
193    download_name = u'scan.pdf'
194    tab_redirect = '#tab2'
195
196    @property
197    def download_filename(self):
198        return u"%s.pdf" % self.context.document_id[:9]
199
200
201class PDFScanEditUpload(PDFScanManageUpload):
202    """Scan upload viewlet for customer.
203    """
204    grok.view(DocumentEditFormPage)
205    grok.require('waeup.handleCustomer')
206
207
208class PDFScanDisplay(FileDisplay):
209    """Scan display viewlet.
210    """
211    grok.order(1)
212    grok.context(PCNCustomerPDFDocument)
213    grok.require('waeup.viewCustomer')
214    grok.view(DocumentDisplayFormPage)
215    label = _(u'PDF Scan')
216    title = _(u'PDF Scan')
217    download_name = u'scan.pdf'
218
219    @property
220    def download_filename(self):
221        return u"%s.pdf" % self.context.document_id[:9]
222
223
224class PDFScanImage(Image):
225    """Scan document.
226    """
227    grok.name('scan.pdf')
228    grok.context(PCNCustomerPDFDocument)
229    grok.require('waeup.viewCustomer')
230    download_name = u'scan.pdf'
231
232    @property
233    def download_filename(self):
234        return u"%s" % self.context.document_id[:9]
235
236class PDFScanSlip(PDFScanDisplay):
237    grok.view(PDFDocumentSlipPage)
Note: See TracBrowser for help on using the repository browser.