source: main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

Last change on this file was 14022, checked in by Henrik Bettermann, 9 years ago

Use defaultFactory.

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1## $Id: interfaces.py 14022 2016-07-07 06:45:09Z 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##
18from zope.interface import Attribute, Interface
19from zope import schema
20from waeup.ikoba.interfaces import (
21    IIkobaObject, validate_id,
22    ContextualDictSourceFactoryBase)
23from waeup.ikoba.schema import FormattedDate
24from waeup.ikoba.interfaces import MessageFactory as _
25from waeup.ikoba.products.productoptions import ProductOptionField
26
27class ConCatSource(ContextualDictSourceFactoryBase):
28    """A contract category source delivers all contract categories
29    provided in the portal.
30    """
31    #: name of dict to deliver from kofa utils.
32    DICT_NAME = 'CON_CATS_DICT'
33
34class IProductsContainer(IIkobaObject):
35    """A container for all kind of product objects.
36
37    """
38
39    description_dict = Attribute(
40        'Description as language dictionary with values in html format')
41
42    description = schema.Text(
43        title = _(u'Description'),
44        required = False,
45        description = _(u'Multilingual content in HTML format'),
46        )
47
48    def addProduct(product):
49        """Add a product.
50        """
51
52class IProduct(IIkobaObject):
53    """A base representation of products.
54
55    """
56    product_id = schema.TextLine(
57        title = _(u'Product Id'),
58        default = u'NA',
59        required = True,
60        constraint=validate_id,
61        )
62
63    title = schema.TextLine(
64        title = _(u'Product Title'),
65        required = True,
66        default = u'Unnamed',
67        )
68
69    contract_title = schema.TextLine(
70        title = _(u'Contract Title'),
71        description = _('Product title is used if empty.'),
72        required = False,
73        )
74
75    contract_category = schema.Choice(
76        title = _(u'Contract Category'),
77        source = ConCatSource(),
78        required = True,
79        )
80
81    options = schema.List(
82        title = _(u'Options/Fees'),
83        value_type = ProductOptionField(),
84        required = False,
85        readonly = False,
86        defaultFactory=list,
87        )
88
89    valid_from = FormattedDate(
90        title = _(u'Valid from'),
91        required = False,
92        show_year = True,
93        )
94
95    valid_to = FormattedDate(
96        title = _(u'Valid to'),
97        required = False,
98        show_year = True,
99        )
100
101    description_dict = Attribute(
102        'Description as language dictionary with values in html format')
103
104    description = schema.Text(
105        title = _(u'Description'),
106        required = False,
107        description = _(u'Multilingual content in HTML format'),
108        )
109
110    tc_dict = Attribute('Terms and Conditions as language dictionary with values in html format')
111
112    terms_and_conditions = schema.Text(
113        title = _(u'Terms and Conditions'),
114        required = False,
115        description = _(u'Multilingual content in HTML format'),
116        )
Note: See TracBrowser for help on using the repository browser.