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

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

Adjust to base package.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1## $Id: fileviewlets.py 12460 2015-01-13 08:18:16Z 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 _
21
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    DocumentDisplayFormPage,
30    DocumentManageFormPage,
31    DocumentEditFormPage,
32    PDFDocumentSlipPage,)
33
34grok.templatedir('browser_templates')
35
36# File viewlets for customer documents
37
38class JPGScanManageUpload(FileUpload):
39    """Scan upload viewlet for officers.
40    """
41    grok.order(1)
42    grok.context(PCNCustomerJPGDocument)
43    grok.view(DocumentManageFormPage)
44    grok.require('waeup.manageCustomer')
45    label = _(u'Sample Scan')
46    title = _(u'Sample Scan')
47    mus = 1024 * 200
48    download_name = u'scan.jpg'
49    tab_redirect = '#tab2'
50
51    @property
52    def download_filename(self):
53        return u"%s.jpg" % self.context.document_id[:9]
54
55
56class JPGScanEditUpload(JPGScanManageUpload):
57    """Scan upload viewlet for customer.
58    """
59    grok.view(DocumentEditFormPage)
60    grok.require('waeup.handleCustomer')
61
62
63class JPGScanDisplay(FileDisplay):
64    """Scan display viewlet.
65    """
66    grok.order(1)
67    grok.context(PCNCustomerJPGDocument)
68    grok.require('waeup.viewCustomer')
69    grok.view(DocumentDisplayFormPage)
70    label = _(u'Sample Scan')
71    title = _(u'Sample Scan')
72    download_name = u'scan.jpg'
73
74    @property
75    def download_filename(self):
76        return u"%s.jpg" % self.context.document_id[:9]
77
78
79class JPGScanImage(Image):
80    """Scan document.
81    """
82    grok.name('scan.jpg')
83    grok.context(PCNCustomerJPGDocument)
84    grok.require('waeup.viewCustomer')
85    download_name = u'scan.jpg'
86
87    @property
88    def download_filename(self):
89        return u"%s.jpg" % self.context.document_id[:9]
90
91class JPGScanPDFSlip(JPGScanDisplay):
92    grok.view(PDFDocumentSlipPage)
93
94
95class PDFScanManageUpload(FileUpload):
96    """Scan upload viewlet for officers.
97    """
98    grok.view(DocumentManageFormPage)
99    grok.context(PCNCustomerPDFDocument)
100    grok.require('waeup.manageCustomer')
101    label = _(u'PDF File')
102    title = _(u'PDF File')
103    mus = 1024 * 1000
104    download_name = u'scan.pdf'
105    tab_redirect = '#tab2'
106
107    @property
108    def download_filename(self):
109        return u"%s.pdf" % self.context.document_id[:9]
110
111
112class PDFScanEditUpload(PDFScanManageUpload):
113    """Scan upload viewlet for customer.
114    """
115    grok.view(DocumentEditFormPage)
116    grok.require('waeup.handleCustomer')
117
118
119class PDFScanDisplay(FileDisplay):
120    """Scan display viewlet.
121    """
122    grok.order(1)
123    grok.context(PCNCustomerPDFDocument)
124    grok.require('waeup.viewCustomer')
125    grok.view(DocumentDisplayFormPage)
126    label = _(u'PDF Scan')
127    title = _(u'PDF Scan')
128    download_name = u'scan.pdf'
129
130    @property
131    def download_filename(self):
132        return u"%s.pdf" % self.context.document_id[:9]
133
134
135class PDFScanImage(Image):
136    """Scan document.
137    """
138    grok.name('scan.pdf')
139    grok.context(PCNCustomerPDFDocument)
140    grok.require('waeup.viewCustomer')
141    download_name = u'scan.pdf'
142
143    @property
144    def download_filename(self):
145        return u"%s" % self.context.document_id[:9]
146
147class PDFScanSlip(PDFScanDisplay):
148    grok.view(PDFDocumentSlipPage)
Note: See TracBrowser for help on using the repository browser.