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

Last change on this file since 12305 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
RevLine 
[12018]1## $Id: interfaces.py 12289 2014-12-21 22:17:06Z 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
[11956]29
[11958]30from waeup.ikoba.customers.vocabularies import (
[12103]31    contextual_reg_num_source, GenderSource, nats_vocab,
32    ConCatProductSource, CustomerDocumentSource)
[11958]33
[11985]34
[11956]35class ICustomersUtils(Interface):
36    """A collection of methods which are subject to customization.
37
38    """
39
[11985]40
[11956]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
[11958]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
[11985]64
[11956]65class ICustomer(IIkobaObject):
66    """Representation of a customer.
67
68    """
69
[11958]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(
[11996]93        title = _(u'Customer Id'),
[11958]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        )
[12260]130
[11958]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
[11985]151
[11958]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
[11985]161
[11958]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
[11967]170    def export_customer(customer, filepath=None):
[11958]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
[11985]178
[12039]179class ICustomerRequestPW(IIkobaObject):
180    """Representation of a customer for first-time password request.
[11967]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        )
[11989]200
201
[12039]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
[11989]230# Customer document interfaces
231
232class ICustomerDocumentsContainer(IDocumentsContainer):
233    """A container for customer document objects.
234
235    """
236
237
238class ICustomerDocument(IDocument):
[12089]239    """A customer document object.
[11989]240
241    """
242
[12166]243    is_editable_by_customer = Attribute('Document editable by customer')
244    is_editable_by_manager = Attribute('Document editable by manager')
[12053]245
[12260]246    document_id = schema.TextLine(
247        title = _(u'Document Id'),
248        required = False,
249        constraint=validate_uuid,
250        )
[12053]251
[12260]252
[12279]253class ICustomerSampleDocument(ICustomerDocument):
254    """A customer sample document object.
255
256    """
257
258
[12260]259class ICustomerPDFDocument(ICustomerDocument):
[12279]260    """A customer pdf document object.
[12053]261
[12089]262    """
263
[12097]264# Customer contract interfaces
[12089]265
[12097]266class IContractsContainer(IIkobaObject):
[12089]267    """A container for customer aplication objects.
268
269    """
270
[12097]271    def addContract(contract):
272        """Add an contract object.
[12089]273        """
274
275
[12097]276class IContract(IIkobaObject):
277    """A customer contract.
[12089]278
279    """
280    history = Attribute('Object history, a list of messages')
[12097]281    state = Attribute('Returns the contract state')
[12089]282    translated_state = Attribute(
283        'Returns a translated, more verbose appliction state')
[12097]284    class_name = Attribute('Name of the contract class')
[12092]285    formatted_transition_date = Attribute(
286        'Last transition formatted date string')
[12097]287    contract_category = Attribute('Category for the grouping of products')
[12094]288    last_product_id = Attribute(
[12097]289        'Id of product recently stored with the contract')
[12167]290    is_editable_by_customer = Attribute('Contract editable by customer')
[12144]291    is_approvable = Attribute('Contract approvable by officer')
[12143]292    translated_class_name = Attribute('Translatable class name')
[12289]293    user_id = Attribute('Id of a user, actually the id of the customer')
[12089]294
[12258]295    contract_id = schema.TextLine(
296        title = _(u'Contract Id'),
297        required = False,
[12260]298        constraint=validate_uuid,
[12258]299        )
300
[12089]301    title = schema.TextLine(
[12097]302        title = _(u'Contract Title'),
[12089]303        required = True,
304        )
305
[12119]306    product_object = schema.Choice(
[12092]307        title = _(u'Product'),
[12098]308        source = ConCatProductSource(),
[12095]309        required = False,
310        )
311
[12103]312
[12097]313class IContractEdit(IContract):
314    """Interface for editing contract data by customers.
[12095]315
316    """
317
[12119]318    product_object = schema.Choice(
[12095]319        title = _(u'Product'),
[12098]320        source = ConCatProductSource(),
[12094]321        required = True,
[12103]322        )
323
324
325class ISampleContract(IContract):
326    """A customer contract sample with document attached.
327
328    """
329
[12119]330    document_object = schema.Choice(
[12103]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
[12119]342    product_object = schema.Choice(
[12103]343        title = _(u'Product'),
344        source = ConCatProductSource(),
345        required = True,
346        )
347
[12119]348    document_object = schema.Choice(
[12103]349        title = _(u'Document'),
350        source = CustomerDocumentSource(),
351        required = True,
[12095]352        )
Note: See TracBrowser for help on using the repository browser.