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

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

Only valid (active) products are selectable in UI.

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