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

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

Renaming batch 2

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