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

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

Save 'terms and conditions' when adding a contract.

Prevent changing product_object after adding contract.

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