1 | ## $Id: documents.py 12384 2015-01-03 18:02:11Z 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 | 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 |
---|
27 | from ikobacustom.pcn.interfaces import MessageFactory as _ |
---|
28 | from ikobacustom.pcn.customers.interfaces import ( |
---|
29 | IPCNCustomerJPGDocument, IPCNCustomerPDFDocument) |
---|
30 | |
---|
31 | |
---|
32 | class PCNCustomerJPGDocument(CustomerDocumentBase): |
---|
33 | """This is a sample customer document. |
---|
34 | """ |
---|
35 | |
---|
36 | grok.implements(IPCNCustomerJPGDocument, ICustomerNavigation) |
---|
37 | grok.provides(IPCNCustomerJPGDocument) |
---|
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. |
---|
43 | filenames = ('scan.jpg',) |
---|
44 | |
---|
45 | form_fields_interface = IPCNCustomerJPGDocument |
---|
46 | |
---|
47 | PCNCustomerJPGDocument = attrs_to_fields(PCNCustomerJPGDocument) |
---|
48 | |
---|
49 | |
---|
50 | class PCNCustomerJPGDocumentFactory(grok.GlobalUtility): |
---|
51 | """A factory for customer documents. |
---|
52 | """ |
---|
53 | grok.implements(IFactory) |
---|
54 | grok.name(u'waeup.PCNCustomerJPGDocument') |
---|
55 | title = u"Create a new document.", |
---|
56 | description = u"This factory instantiates new document instances." |
---|
57 | |
---|
58 | def __call__(self, *args, **kw): |
---|
59 | return PCNCustomerJPGDocument(*args, **kw) |
---|
60 | |
---|
61 | def getInterfaces(self): |
---|
62 | return implementedBy(PCNCustomerJPGDocument) |
---|
63 | |
---|
64 | class PCNCustomerPDFDocument(CustomerDocumentBase): |
---|
65 | """This is a sample customer document. |
---|
66 | """ |
---|
67 | |
---|
68 | grok.implements(IPCNCustomerPDFDocument, ICustomerNavigation) |
---|
69 | grok.provides(IPCNCustomerPDFDocument) |
---|
70 | |
---|
71 | filenames = ('scan.pdf',) |
---|
72 | |
---|
73 | form_fields_interface = IPCNCustomerPDFDocument |
---|
74 | |
---|
75 | PCNCustomerPDFDocument = attrs_to_fields(PCNCustomerPDFDocument) |
---|
76 | |
---|
77 | |
---|
78 | class PCNCustomerPDFDocumentFactory(grok.GlobalUtility): |
---|
79 | """A factory for customer documents. |
---|
80 | """ |
---|
81 | grok.implements(IFactory) |
---|
82 | grok.name(u'waeup.PCNCustomerPDFDocument') |
---|
83 | title = u"Create a new document.", |
---|
84 | description = u"This factory instantiates new document instances." |
---|
85 | |
---|
86 | def __call__(self, *args, **kw): |
---|
87 | return PCNCustomerPDFDocument(*args, **kw) |
---|
88 | |
---|
89 | def getInterfaces(self): |
---|
90 | return implementedBy(PCNCustomerPDFDocument) |
---|