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

Last change on this file since 15284 was 13068, checked in by Henrik Bettermann, 9 years ago

Rename views.

  • Property svn:keywords set to Id
File size: 6.6 KB
RevLine 
[12373]1## $Id: fileviewlets.py 13068 2015-06-16 14:50:12Z 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
19import grok
20from waeup.ikoba.interfaces import MessageFactory as _
[12534]21from waeup.ikoba.customers.interfaces import ICustomer
[12355]22from waeup.ikoba.browser.fileviewlets import (
23    FileDisplay, FileUpload, Image)
24
[12384]25from ikobacustom.pcn.customers.documents import (
26    PCNCustomerJPGDocument, PCNCustomerPDFDocument)
[12355]27
28from waeup.ikoba.customers.browser import (
[12534]29    CustomerBaseDisplayFormPage,
30    CustomerBaseManageFormPage,
31    CustomerFilesUploadPage,
[12355]32    DocumentDisplayFormPage,
33    DocumentManageFormPage,
34    DocumentEditFormPage,
[13068]35    PDFDocumentSlip)
[12355]36
37grok.templatedir('browser_templates')
38
[12534]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
[12557]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
[12355]125# File viewlets for customer documents
126
[12384]127class JPGScanManageUpload(FileUpload):
[12355]128    """Scan upload viewlet for officers.
129    """
130    grok.order(1)
[12384]131    grok.context(PCNCustomerJPGDocument)
[12355]132    grok.view(DocumentManageFormPage)
133    grok.require('waeup.manageCustomer')
134    label = _(u'Sample Scan')
135    title = _(u'Sample Scan')
[12403]136    mus = 1024 * 200
[12384]137    download_name = u'scan.jpg'
[12355]138    tab_redirect = '#tab2'
139
[12460]140    @property
141    def download_filename(self):
142        return u"%s.jpg" % self.context.document_id[:9]
[12355]143
[12460]144
[12384]145class JPGScanEditUpload(JPGScanManageUpload):
[12355]146    """Scan upload viewlet for customer.
147    """
148    grok.view(DocumentEditFormPage)
149    grok.require('waeup.handleCustomer')
150
151
[12384]152class JPGScanDisplay(FileDisplay):
[12355]153    """Scan display viewlet.
154    """
155    grok.order(1)
[12384]156    grok.context(PCNCustomerJPGDocument)
[12355]157    grok.require('waeup.viewCustomer')
158    grok.view(DocumentDisplayFormPage)
159    label = _(u'Sample Scan')
160    title = _(u'Sample Scan')
[12384]161    download_name = u'scan.jpg'
[12355]162
[12460]163    @property
164    def download_filename(self):
165        return u"%s.jpg" % self.context.document_id[:9]
[12355]166
[12460]167
[12384]168class JPGScanImage(Image):
[12355]169    """Scan document.
170    """
[12384]171    grok.name('scan.jpg')
172    grok.context(PCNCustomerJPGDocument)
[12355]173    grok.require('waeup.viewCustomer')
[12384]174    download_name = u'scan.jpg'
[12355]175
[12460]176    @property
177    def download_filename(self):
178        return u"%s.jpg" % self.context.document_id[:9]
179
[12384]180class JPGScanPDFSlip(JPGScanDisplay):
[13068]181    grok.view(PDFDocumentSlip)
[12355]182
183
184class PDFScanManageUpload(FileUpload):
185    """Scan upload viewlet for officers.
186    """
187    grok.view(DocumentManageFormPage)
[12384]188    grok.context(PCNCustomerPDFDocument)
[12355]189    grok.require('waeup.manageCustomer')
190    label = _(u'PDF File')
191    title = _(u'PDF File')
[12403]192    mus = 1024 * 1000
[12384]193    download_name = u'scan.pdf'
[12355]194    tab_redirect = '#tab2'
195
[12460]196    @property
197    def download_filename(self):
198        return u"%s.pdf" % self.context.document_id[:9]
[12355]199
[12460]200
[12355]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)
[12384]212    grok.context(PCNCustomerPDFDocument)
[12355]213    grok.require('waeup.viewCustomer')
214    grok.view(DocumentDisplayFormPage)
215    label = _(u'PDF Scan')
216    title = _(u'PDF Scan')
[12384]217    download_name = u'scan.pdf'
[12355]218
[12460]219    @property
220    def download_filename(self):
221        return u"%s.pdf" % self.context.document_id[:9]
[12355]222
[12460]223
[12355]224class PDFScanImage(Image):
225    """Scan document.
226    """
[12384]227    grok.name('scan.pdf')
228    grok.context(PCNCustomerPDFDocument)
[12355]229    grok.require('waeup.viewCustomer')
[12384]230    download_name = u'scan.pdf'
[12355]231
[12460]232    @property
233    def download_filename(self):
234        return u"%s" % self.context.document_id[:9]
235
[12355]236class PDFScanSlip(PDFScanDisplay):
[13068]237    grok.view(PDFDocumentSlip)
Note: See TracBrowser for help on using the repository browser.