source: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py @ 12324

Last change on this file since 12324 was 12324, checked in by Henrik Bettermann, 10 years ago

Add product_options field.

  • Property svn:keywords set to Id
File size: 9.5 KB
Line 
1## $Id: interfaces.py 12324 2014-12-26 09:35:21Z 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#from datetime import datetime
19from zope.component import getUtility
20from zope.interface import Attribute, Interface
21from zope import schema
22from zc.sourcefactory.contextual import BasicContextualSourceFactory
23from waeup.ikoba.interfaces import MessageFactory as _
24from waeup.ikoba.interfaces import (
25    IIkobaObject, validate_email, ICSVExporter, validate_uuid)
26from waeup.ikoba.schema import TextLineChoice, FormattedDate, PhoneNumber
27from waeup.ikoba.browser.interfaces import ICustomerNavigationBase
28from waeup.ikoba.documents.interfaces import IDocumentsContainer, IDocument
29
30from waeup.ikoba.customers.vocabularies import (
31    contextual_reg_num_source, GenderSource, nats_vocab,
32    ConCatProductSource, CustomerDocumentSource,
33    ProductOptionSource)
34
35
36class ICustomersUtils(Interface):
37    """A collection of methods which are subject to customization.
38
39    """
40
41
42class ICustomersContainer(IIkobaObject):
43    """A customers container contains company customers.
44
45    """
46    def addCustomer(customer):
47        """Add an ICustomer object and subcontainers.
48
49        """
50
51    unique_customer_id = Attribute("""A unique customer id.""")
52
53
54class ICustomerNavigation(ICustomerNavigationBase):
55    """Interface needed for custom navigation, logging, etc.
56
57    """
58    customer = Attribute('Customer object of context.')
59
60    def writeLogMessage(view, message):
61        """Write a view specific log message into custom.log.
62
63        """
64
65
66class ICustomer(IIkobaObject):
67    """Representation of a customer.
68
69    """
70
71    history = Attribute('Object history, a list of messages')
72    state = Attribute('Returns the registration state of a customer')
73    password = Attribute('Encrypted password of a customer')
74    temp_password = Attribute(
75        'Dictionary with user name, timestamp and encrypted password')
76    fullname = Attribute('All name parts separated by hyphens')
77    display_fullname = Attribute('The fullname of an applicant')
78
79    suspended = schema.Bool(
80        title = _(u'Account suspended'),
81        default = False,
82        required = False,
83        )
84
85    suspended_comment = schema.Text(
86        title = _(u"Reasons for Deactivation"),
87        required = False,
88        description = _(
89            u'This message will be shown if and only if deactivated '
90            'customers try to login.'),
91        )
92
93    customer_id = schema.TextLine(
94        title = _(u'Customer Id'),
95        required = False,
96        )
97
98    firstname = schema.TextLine(
99        title = _(u'First Name'),
100        required = True,
101        )
102
103    middlename = schema.TextLine(
104        title = _(u'Middle Name'),
105        required = False,
106        )
107
108    lastname = schema.TextLine(
109        title = _(u'Last Name (Surname)'),
110        required = True,
111        )
112
113    sex = schema.Choice(
114        title = _(u'Sex'),
115        source = GenderSource(),
116        required = True,
117        )
118
119    reg_number = TextLineChoice(
120        title = _(u'Registration Number'),
121        required = True,
122        readonly = False,
123        source = contextual_reg_num_source,
124        )
125
126    email = schema.ASCIILine(
127        title = _(u'Email'),
128        required = False,
129        constraint=validate_email,
130        )
131
132    phone = PhoneNumber(
133        title = _(u'Phone'),
134        description = u'',
135        required = False,
136        )
137
138    def setTempPassword(user, password):
139        """Set a temporary password (LDAP-compatible) SSHA encoded for
140        officers.
141
142        """
143
144    def getTempPassword():
145        """Check if a temporary password has been set and if it
146        is not expired.
147
148        Return the temporary password if valid,
149        None otherwise. Unset the temporary password if expired.
150        """
151
152
153class ICustomerUpdateByRegNo(ICustomer):
154    """Representation of a customer. Skip regular reg_number validation.
155
156    """
157    reg_number = schema.TextLine(
158        title = _(u'Registration Number'),
159        required = False,
160        )
161
162
163class ICSVCustomerExporter(ICSVExporter):
164    """A regular ICSVExporter that additionally supports exporting
165      data from a given customer object.
166    """
167    def get_filtered(site, **kw):
168        """Get a filtered set of customer.
169        """
170
171    def export_customer(customer, filepath=None):
172        """Export data for a given customer.
173        """
174
175    def export_filtered(site, filepath=None, **kw):
176        """Export filtered set of customers.
177        """
178
179
180class ICustomerRequestPW(IIkobaObject):
181    """Representation of a customer for first-time password request.
182
183    This interface is used when customers use the requestpw page to
184    login for the the first time.
185    """
186    number = schema.TextLine(
187        title = _(u'Registration Number'),
188        required = True,
189        )
190
191    firstname = schema.TextLine(
192        title = _(u'First Name'),
193        required = True,
194        )
195
196    email = schema.ASCIILine(
197        title = _(u'Email Address'),
198        required = True,
199        constraint=validate_email,
200        )
201
202
203class ICustomerCreate(IIkobaObject):
204    """Representation of an customer for account creation.
205
206    This interface is used when customers use the createaccount page.
207    """
208
209    firstname = schema.TextLine(
210        title = _(u'First Name'),
211        required = True,
212        )
213
214    middlename = schema.TextLine(
215        title = _(u'Middle Name'),
216        required = False,
217        )
218
219    lastname = schema.TextLine(
220        title = _(u'Last Name (Surname)'),
221        required = True,
222        )
223
224    email = schema.ASCIILine(
225        title = _(u'Email Address'),
226        required = True,
227        constraint=validate_email,
228        )
229
230
231# Customer document interfaces
232
233class ICustomerDocumentsContainer(IDocumentsContainer):
234    """A container for customer document objects.
235
236    """
237
238
239class ICustomerDocument(IDocument):
240    """A customer document object.
241
242    """
243
244    is_editable_by_customer = Attribute('Document editable by customer')
245    is_editable_by_manager = Attribute('Document editable by manager')
246
247    document_id = schema.TextLine(
248        title = _(u'Document Id'),
249        required = False,
250        constraint=validate_uuid,
251        )
252
253
254class ICustomerSampleDocument(ICustomerDocument):
255    """A customer sample document object.
256
257    """
258
259
260class ICustomerPDFDocument(ICustomerDocument):
261    """A customer pdf document object.
262
263    """
264
265# Customer contract interfaces
266
267class IContractsContainer(IIkobaObject):
268    """A container for customer aplication objects.
269
270    """
271
272    def addContract(contract):
273        """Add an contract object.
274        """
275
276
277class IContract(IIkobaObject):
278    """A customer contract.
279
280    """
281    history = Attribute('Object history, a list of messages')
282    state = Attribute('Returns the contract state')
283    translated_state = Attribute(
284        'Returns a translated, more verbose appliction state')
285    class_name = Attribute('Name of the contract class')
286    formatted_transition_date = Attribute(
287        'Last transition formatted date string')
288    contract_category = Attribute('Category for the grouping of products')
289    last_product_id = Attribute(
290        'Id of product recently stored with the contract')
291    is_editable_by_customer = Attribute('Contract editable by customer')
292    is_approvable = Attribute('Contract approvable by officer')
293    translated_class_name = Attribute('Translatable class name')
294    user_id = Attribute('Id of a user, actually the id of the customer')
295
296    contract_id = schema.TextLine(
297        title = _(u'Contract Id'),
298        required = False,
299        constraint=validate_uuid,
300        )
301
302    title = schema.TextLine(
303        title = _(u'Contract Title'),
304        required = True,
305        )
306
307    product_object = schema.Choice(
308        title = _(u'Product'),
309        source = ConCatProductSource(),
310        required = False,
311        )
312
313    product_options = schema.List(
314        title = _(u'Options/Fees'),
315        value_type = schema.Choice(
316            source=ProductOptionSource(),
317            required = True,
318            ),
319        required = False,
320        readonly = False,
321        default = [],
322        )
323
324
325class IContractEdit(IContract):
326    """Interface for editing contract data by customers.
327
328    """
329
330    product_object = schema.Choice(
331        title = _(u'Product'),
332        source = ConCatProductSource(),
333        required = True,
334        )
335
336
337class ISampleContract(IContract):
338    """A customer contract sample with document attached.
339
340    """
341
342    document_object = schema.Choice(
343        title = _(u'Document'),
344        source = CustomerDocumentSource(),
345        required = False,
346        )
347
348
349class ISampleContractEdit(ISampleContract):
350    """Interface for editing sample contract data by customers.
351
352    """
353
354    product_object = schema.Choice(
355        title = _(u'Product'),
356        source = ConCatProductSource(),
357        required = True,
358        )
359
360    document_object = schema.Choice(
361        title = _(u'Document'),
362        source = CustomerDocumentSource(),
363        required = True,
364        )
Note: See TracBrowser for help on using the repository browser.