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

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

Add more fields.

  • Property svn:keywords set to Id
File size: 4.0 KB
RevLine 
[12372]1## $Id: fileviewlets.py 14203 2016-09-29 07:17:39Z 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 _
21
22from waeup.ikoba.browser.fileviewlets import (
23    FileDisplay, FileUpload, Image)
24
[14184]25from ikobacustom.uniben.customers.documents import (
[14197]26    UnibenCustomerPDFDocument,
27    UnibenCustomerJPGDocument)
[12355]28
29from waeup.ikoba.customers.browser import (
30    DocumentDisplayFormPage,
31    DocumentManageFormPage,
32    DocumentEditFormPage,
[13067]33    PDFDocumentSlip,)
[12355]34
35grok.templatedir('browser_templates')
36
37# File viewlets for customer documents
38
[14197]39class JPGScanManageUpload(FileUpload):
[12355]40    """Scan upload viewlet for officers.
41    """
42    grok.order(1)
[14197]43    grok.context(UnibenCustomerJPGDocument)
[12355]44    grok.view(DocumentManageFormPage)
45    grok.require('waeup.manageCustomer')
[14197]46    label = _(u'JPG File')
47    title = _(u'JPG File')
[14203]48    mus = 1024 * 1000
[14197]49    download_name = u'scan.jpg'
[12355]50    tab_redirect = '#tab2'
51
[14197]52    @property
53    def download_filename(self):
54        return u"%s.jpg" % self.context.document_id[:9]
[12355]55
[14197]56
57class JPGScanEditUpload(JPGScanManageUpload):
[12355]58    """Scan upload viewlet for customer.
59    """
60    grok.view(DocumentEditFormPage)
61    grok.require('waeup.handleCustomer')
62
63
[14197]64class JPGScanDisplay(FileDisplay):
[12355]65    """Scan display viewlet.
66    """
67    grok.order(1)
[14197]68    grok.context(UnibenCustomerJPGDocument)
[12355]69    grok.require('waeup.viewCustomer')
70    grok.view(DocumentDisplayFormPage)
[14197]71    label = _(u'JPG File')
72    title = _(u'JPG File')
73    download_name = u'scan.jpg'
[12355]74
[14197]75    @property
76    def download_filename(self):
77        return u"%s.jpg" % self.context.document_id[:9]
[12355]78
[14197]79
80class JPGScanImage(Image):
[12355]81    """Scan document.
82    """
[14197]83    grok.name('scan.jpg')
84    grok.context(UnibenCustomerJPGDocument)
[12355]85    grok.require('waeup.viewCustomer')
[14197]86    download_name = u'scan.jpg'
[12355]87
[14197]88    @property
89    def download_filename(self):
90        return u"%s.jpg" % self.context.document_id[:9]
[12459]91
[14197]92class JPGScanPDFSlip(JPGScanDisplay):
[13067]93    grok.view(PDFDocumentSlip)
[12355]94
[14197]95
[14184]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)
[14197]127    label = _(u'PDF File')
128    title = _(u'PDF File')
[14184]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.