source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/interfaces.py @ 12677

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

Extend contract workflow to integrate payment.

Prepare (empty) page to select payment method and finally create a payment object.

  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1## $Id: interfaces.py 12663 2015-03-05 07:28:31Z 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    valid_from = Attribute('Contract valid from')
304    valid_to = Attribute('Contract valid to')
305    fee_based = Attribute('Fee based contract')
306
307    contract_id = schema.TextLine(
308        title = _(u'Contract Id'),
309        required = False,
310        constraint=validate_uuid,
311        )
312
313    product_object = schema.Choice(
314        title = _(u'Product'),
315        source = ConCatProductSource(),
316        required = False,
317        )
318
319    product_options = schema.List(
320        title = _(u'Options/Fees'),
321        value_type = schema.Choice(
322            source=ProductOptionSourceFactory(),
323            required = True,
324            ),
325        required = False,
326        readonly = False,
327        default = [],
328        )
329
330
331class IContractSelectProduct(Interface):
332    """Interface for for the ContractSelectProductPage.
333
334    """
335
336    product_object = schema.Choice(
337        title = _(u'Product'),
338        source = ConCatActiveProductSource(),
339        required = True,
340        )
341
342
343class ISampleContract(IContract):
344    """A customer contract sample with document attached.
345
346    """
347
348    document_object = schema.Choice(
349        title = _(u'Document'),
350        source = CustomerDocumentSource(),
351        required = False,
352        )
353
354
355class ISampleContractOfficialUse(IIkobaObject):
356    """Interface for official use only.
357    """
358
359    comment = schema.Text(
360        title = _(u'Comment'),
361        required = False,
362        )
363
364
365class ISampleContractProcess(ISampleContract, ISampleContractOfficialUse):
366    """Interface for processing contract data.
367    """
368
369    #title = schema.TextLine(
370    #    required = False,
371    #    )
372
373    #tc_dict = schema.Dict(
374    #    required = False,
375    #    default = {},
376    #    )
377
378    product_options = schema.List(
379        value_type = ProductOptionField(),
380        required = False,
381        readonly = False,
382        default = [],
383        )
384
385
386class ISampleContractEdit(ISampleContract):
387    """Interface for editing sample contract data by customers.
388
389    """
390
391    document_object = schema.Choice(
392        title = _(u'Document'),
393        source = CustomerDocumentSource(),
394        required = True,
395        )
Note: See TracBrowser for help on using the repository browser.