source: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/fileviewlets.py @ 17952

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

Rename customer views which are not layout-aware and thus not pages.

  • Property svn:keywords set to Id
File size: 5.1 KB
RevLine 
[12035]1## $Id: fileviewlets.py 13066 2015-06-16 14:48:55Z henrik $
[11971]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
[12223]22from waeup.ikoba.browser.fileviewlets import (
23    FileDisplay, FileUpload, Image)
24
[12224]25from waeup.ikoba.customers.interfaces import ICustomer
[12057]26
27from waeup.ikoba.customers.documents import (
28    CustomerSampleDocument, CustomerPDFDocument
29    )
[11971]30from waeup.ikoba.customers.browser import (
31    CustomerBaseDisplayFormPage, CustomerBaseManageFormPage,
[12035]32    CustomerFilesUploadPage,
[12050]33    DocumentDisplayFormPage, DocumentManageFormPage, DocumentEditFormPage,
[13066]34    PDFDocumentSlip,)
[11971]35
36grok.templatedir('browser_templates')
37
[11988]38# File viewlets for customer base page
39
[11971]40class PassportDisplay(FileDisplay):
41    """Passport display viewlet.
42    """
43    grok.order(1)
44    grok.context(ICustomer)
[11987]45    grok.view(CustomerBaseDisplayFormPage)
[11971]46    grok.require('waeup.viewCustomer')
47    grok.template('imagedisplay')
48    label = _(u'Passport Picture')
49    download_name = u'passport.jpg'
50
[11985]51
[12038]52class PassportManageUpload(FileUpload):
[11971]53    """Passport upload viewlet for officers.
54    """
55    grok.order(1)
56    grok.context(ICustomer)
[11987]57    grok.view(CustomerBaseManageFormPage)
[11971]58    grok.require('waeup.manageCustomer')
59    grok.template('imageupload')
60    label = _(u'Passport Picture (jpg only)')
61    mus = 1024 * 50
62    download_name = u'passport.jpg'
63    tab_redirect = '#tab2'
64
[11985]65
[12038]66class PassportEditUpload(PassportManageUpload):
[11971]67    """Passport upload viewlet for customers.
68    """
69    grok.view(CustomerFilesUploadPage)
[12347]70    grok.require('waeup.handleCustomer')
[11971]71
[11985]72
[11971]73class Passport(Image):
74    """Renders jpeg passport picture.
75    """
76    grok.name('passport.jpg')
77    download_name = u'passport.jpg'
78    grok.context(ICustomer)
[11988]79    grok.require('waeup.viewCustomer')
80
81# File viewlets for customer documents
[12035]82
[12062]83class SampleScanManageUpload(FileUpload):
[12038]84    """Scan upload viewlet for officers.
[12035]85    """
86    grok.order(1)
[12057]87    grok.context(CustomerSampleDocument)
[12035]88    grok.view(DocumentManageFormPage)
89    grok.require('waeup.manageCustomer')
[12057]90    label = _(u'Sample Scan')
91    title = _(u'Sample Scan')
[12408]92    mus = 1024 * 200
[12057]93    download_name = u'sample'
[12446]94    download_filename = download_name
[12035]95    tab_redirect = '#tab2'
96
[12036]97
[12062]98class SampleScanEditUpload(SampleScanManageUpload):
[12038]99    """Scan upload viewlet for customer.
[12444]100
101    If a user has both permissions, waeup.manageCustomer and
102    waeup.handleCustomer, the upload viewlet appears twice.
[12036]103    """
104    grok.view(DocumentEditFormPage)
105    grok.require('waeup.handleCustomer')
106
107
[12062]108class SampleScanDisplay(FileDisplay):
[12038]109    """Scan display viewlet.
[12035]110    """
111    grok.order(1)
[12057]112    grok.context(CustomerSampleDocument)
[12035]113    grok.require('waeup.viewCustomer')
114    grok.view(DocumentDisplayFormPage)
[12057]115    label = _(u'Sample Scan')
116    title = _(u'Sample Scan')
117    download_name = u'sample'
[12446]118    download_filename = download_name
[12035]119
[12036]120
[12057]121class SampleScanImage(Image):
[12038]122    """Scan document.
[12035]123    """
[12446]124
[12057]125    grok.name('sample')
126    grok.context(CustomerSampleDocument)
[12035]127    grok.require('waeup.viewCustomer')
[12057]128    download_name = u'sample'
[12446]129    download_filename = download_name
[12057]130
[12444]131
[12062]132class SampleScanPDFSlip(SampleScanDisplay):
[13066]133    grok.view(PDFDocumentSlip)
[12057]134
[12062]135
136class PDFScanManageUpload(FileUpload):
[12057]137    """Scan upload viewlet for officers.
138    """
139    grok.view(DocumentManageFormPage)
140    grok.context(CustomerPDFDocument)
141    grok.require('waeup.manageCustomer')
142    label = _(u'PDF File')
143    title = _(u'PDF File')
[12408]144    mus = 1024 * 1000
[12058]145    download_name = u'sample.pdf'
[12057]146    tab_redirect = '#tab2'
147
[12446]148    @property
149    def download_filename(self):
150        return u"%s.pdf" % self.context.document_id[:9]
[12057]151
[12446]152
[12062]153class PDFScanEditUpload(PDFScanManageUpload):
[12057]154    """Scan upload viewlet for customer.
155    """
156    grok.view(DocumentEditFormPage)
157    grok.require('waeup.handleCustomer')
158
159
[12062]160class PDFScanDisplay(FileDisplay):
[12057]161    """Scan display viewlet.
162    """
163    grok.order(1)
164    grok.context(CustomerPDFDocument)
165    grok.require('waeup.viewCustomer')
166    grok.view(DocumentDisplayFormPage)
167    label = _(u'PDF Scan')
168    title = _(u'PDF Scan')
[12058]169    download_name = u'sample.pdf'
[12057]170
[12446]171    @property
172    def download_filename(self):
173        return u"%s.pdf" % self.context.document_id[:9]
[12057]174
[12446]175
[12057]176class PDFScanImage(Image):
177    """Scan document.
178    """
[12058]179    grok.name('sample.pdf')
[12057]180    grok.context(CustomerPDFDocument)
181    grok.require('waeup.viewCustomer')
[12058]182    download_name = u'sample.pdf'
[12062]183
[12446]184    @property
185    def download_filename(self):
186        return u"%s" % self.context.document_id[:9]
[12444]187
[12446]188
[12062]189class PDFScanSlip(PDFScanDisplay):
[13066]190    grok.view(PDFDocumentSlip)
Note: See TracBrowser for help on using the repository browser.