source: main/ikobacustom.uniben/trunk/src/ikobacustom/uniben/customers/fileviewlets.py @ 17929

Last change on this file since 17929 was 14203, checked in by Henrik Bettermann, 8 years ago

Add more fields.

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