[12286] | 1 | ## $Id: documents.py 14197 2016-09-28 07:04:12Z henrik $ |
---|
[12273] | 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 | Customer document components. |
---|
| 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.component.interfaces import IFactory |
---|
| 23 | from zope.interface import implementedBy |
---|
| 24 | from waeup.ikoba.utils.helpers import attrs_to_fields |
---|
| 25 | from waeup.ikoba.customers.interfaces import ICustomerNavigation |
---|
| 26 | from waeup.ikoba.customers.documents import CustomerDocumentBase |
---|
[14178] | 27 | from ikobacustom.uniben.interfaces import MessageFactory as _ |
---|
[14184] | 28 | from ikobacustom.uniben.customers.interfaces import ( |
---|
[14197] | 29 | IUnibenCustomerPDFDocument, |
---|
| 30 | IUnibenCustomerJPGDocument) |
---|
[12273] | 31 | |
---|
[14197] | 32 | class UnibenCustomerJPGDocument(CustomerDocumentBase): |
---|
| 33 | """This is a customer jpg document. |
---|
[12273] | 34 | """ |
---|
| 35 | |
---|
[14197] | 36 | grok.implements(IUnibenCustomerJPGDocument, ICustomerNavigation) |
---|
| 37 | grok.provides(IUnibenCustomerJPGDocument) |
---|
[12273] | 38 | |
---|
| 39 | # Ikoba can store any number of files per Document object. |
---|
| 40 | # However, we highly recommend to associate and store |
---|
| 41 | # only one file per Document object. Thus the following |
---|
| 42 | # tuple should contain only a single filename string. |
---|
[14197] | 43 | filenames = ('scan.jpg',) |
---|
[12273] | 44 | |
---|
[14197] | 45 | form_fields_interface = IUnibenCustomerJPGDocument |
---|
[12273] | 46 | |
---|
[14197] | 47 | UnibenCustomerJPGDocument = attrs_to_fields(UnibenCustomerJPGDocument) |
---|
[12273] | 48 | |
---|
| 49 | |
---|
[14197] | 50 | class UnibenCustomerJPGDocumentFactory(grok.GlobalUtility): |
---|
| 51 | """A factory for customer jpg documents. |
---|
[12273] | 52 | """ |
---|
| 53 | grok.implements(IFactory) |
---|
[14197] | 54 | grok.name(u'waeup.UnibenCustomerJPGDocument') |
---|
[12273] | 55 | title = u"Create a new document.", |
---|
[14197] | 56 | description = u"This factory instantiates new document instances." |
---|
[12273] | 57 | |
---|
| 58 | def __call__(self, *args, **kw): |
---|
[14197] | 59 | return UnibenCustomerJPGDocument(*args, **kw) |
---|
[12273] | 60 | |
---|
| 61 | def getInterfaces(self): |
---|
[14197] | 62 | return implementedBy(UnibenCustomerJPGDocument) |
---|
[14184] | 63 | |
---|
[14197] | 64 | |
---|
[14184] | 65 | class UnibenCustomerPDFDocument(CustomerDocumentBase): |
---|
| 66 | """This is a sample customer document. |
---|
| 67 | """ |
---|
| 68 | |
---|
| 69 | grok.implements(IUnibenCustomerPDFDocument, ICustomerNavigation) |
---|
| 70 | grok.provides(IUnibenCustomerPDFDocument) |
---|
| 71 | |
---|
| 72 | filenames = ('scan.pdf',) |
---|
| 73 | |
---|
| 74 | form_fields_interface = IUnibenCustomerPDFDocument |
---|
| 75 | |
---|
| 76 | UnibenCustomerPDFDocument = attrs_to_fields(UnibenCustomerPDFDocument) |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | class UnibenCustomerPDFDocumentFactory(grok.GlobalUtility): |
---|
| 80 | """A factory for customer documents. |
---|
| 81 | """ |
---|
| 82 | grok.implements(IFactory) |
---|
| 83 | grok.name(u'waeup.UnibenCustomerPDFDocument') |
---|
| 84 | title = u"Create a new document.", |
---|
| 85 | description = u"This factory instantiates new document instances." |
---|
| 86 | |
---|
| 87 | def __call__(self, *args, **kw): |
---|
| 88 | return UnibenCustomerPDFDocument(*args, **kw) |
---|
| 89 | |
---|
| 90 | def getInterfaces(self): |
---|
| 91 | return implementedBy(UnibenCustomerPDFDocument) |
---|