1 | ## $Id: fileviewlets.py 14184 2016-09-23 16:38:53Z 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 | |
---|
19 | import grok |
---|
20 | from waeup.ikoba.interfaces import MessageFactory as _ |
---|
21 | |
---|
22 | from waeup.ikoba.browser.fileviewlets import ( |
---|
23 | FileDisplay, FileUpload, Image) |
---|
24 | |
---|
25 | from ikobacustom.uniben.customers.documents import ( |
---|
26 | UnibenCustomerDocument, UnibenCustomerPDFDocument) |
---|
27 | |
---|
28 | from waeup.ikoba.customers.browser import ( |
---|
29 | DocumentDisplayFormPage, |
---|
30 | DocumentManageFormPage, |
---|
31 | DocumentEditFormPage, |
---|
32 | PDFDocumentSlip,) |
---|
33 | |
---|
34 | grok.templatedir('browser_templates') |
---|
35 | |
---|
36 | # File viewlets for customer documents |
---|
37 | |
---|
38 | class SampleScanManageUpload(FileUpload): |
---|
39 | """Scan upload viewlet for officers. |
---|
40 | """ |
---|
41 | grok.order(1) |
---|
42 | grok.context(UnibenCustomerDocument) |
---|
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'sample' |
---|
49 | download_filename = download_name |
---|
50 | tab_redirect = '#tab2' |
---|
51 | |
---|
52 | |
---|
53 | class SampleScanEditUpload(SampleScanManageUpload): |
---|
54 | """Scan upload viewlet for customer. |
---|
55 | """ |
---|
56 | grok.view(DocumentEditFormPage) |
---|
57 | grok.require('waeup.handleCustomer') |
---|
58 | |
---|
59 | |
---|
60 | class SampleScanDisplay(FileDisplay): |
---|
61 | """Scan display viewlet. |
---|
62 | """ |
---|
63 | grok.order(1) |
---|
64 | grok.context(UnibenCustomerDocument) |
---|
65 | grok.require('waeup.viewCustomer') |
---|
66 | grok.view(DocumentDisplayFormPage) |
---|
67 | label = _(u'Sample Scan') |
---|
68 | title = _(u'Sample Scan') |
---|
69 | download_name = u'sample' |
---|
70 | download_filename = download_name |
---|
71 | |
---|
72 | |
---|
73 | class SampleScanImage(Image): |
---|
74 | """Scan document. |
---|
75 | """ |
---|
76 | grok.name('sample') |
---|
77 | grok.context(UnibenCustomerDocument) |
---|
78 | grok.require('waeup.viewCustomer') |
---|
79 | download_name = u'sample' |
---|
80 | download_filename = download_name |
---|
81 | |
---|
82 | |
---|
83 | class SampleScanPDFSlip(SampleScanDisplay): |
---|
84 | grok.view(PDFDocumentSlip) |
---|
85 | |
---|
86 | class PDFScanManageUpload(FileUpload): |
---|
87 | """Scan upload viewlet for officers. |
---|
88 | """ |
---|
89 | grok.view(DocumentManageFormPage) |
---|
90 | grok.context(UnibenCustomerPDFDocument) |
---|
91 | grok.require('waeup.manageCustomer') |
---|
92 | label = _(u'PDF File') |
---|
93 | title = _(u'PDF File') |
---|
94 | mus = 1024 * 1000 |
---|
95 | download_name = u'scan.pdf' |
---|
96 | tab_redirect = '#tab2' |
---|
97 | |
---|
98 | @property |
---|
99 | def download_filename(self): |
---|
100 | return u"%s.pdf" % self.context.document_id[:9] |
---|
101 | |
---|
102 | |
---|
103 | class PDFScanEditUpload(PDFScanManageUpload): |
---|
104 | """Scan upload viewlet for customer. |
---|
105 | """ |
---|
106 | grok.view(DocumentEditFormPage) |
---|
107 | grok.require('waeup.handleCustomer') |
---|
108 | |
---|
109 | |
---|
110 | class PDFScanDisplay(FileDisplay): |
---|
111 | """Scan display viewlet. |
---|
112 | """ |
---|
113 | grok.order(1) |
---|
114 | grok.context(UnibenCustomerPDFDocument) |
---|
115 | grok.require('waeup.viewCustomer') |
---|
116 | grok.view(DocumentDisplayFormPage) |
---|
117 | label = _(u'PDF Scan') |
---|
118 | title = _(u'PDF Scan') |
---|
119 | download_name = u'scan.pdf' |
---|
120 | |
---|
121 | @property |
---|
122 | def download_filename(self): |
---|
123 | return u"%s.pdf" % self.context.document_id[:9] |
---|
124 | |
---|
125 | |
---|
126 | class PDFScanImage(Image): |
---|
127 | """Scan document. |
---|
128 | """ |
---|
129 | grok.name('scan.pdf') |
---|
130 | grok.context(UnibenCustomerPDFDocument) |
---|
131 | grok.require('waeup.viewCustomer') |
---|
132 | download_name = u'scan.pdf' |
---|
133 | |
---|
134 | @property |
---|
135 | def download_filename(self): |
---|
136 | return u"%s" % self.context.document_id[:9] |
---|
137 | |
---|
138 | class PDFScanSlip(PDFScanDisplay): |
---|
139 | grok.view(PDFDocumentSlip) |
---|