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

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

Uups, we forgot to index and export the contract user_id which is always the customer_id for contracts.

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