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

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

Email address must be required.

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