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

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

Add contract exporter.

  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1## $Id: interfaces.py 12143 2014-12-04 12:22:03Z 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,
32    ConCatProductSource, CustomerDocumentSource)
33
34
35class ICustomersUtils(Interface):
36    """A collection of methods which are subject to customization.
37
38    """
39
40
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
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
64
65class ICustomer(IIkobaObject):
66    """Representation of a customer.
67
68    """
69
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(
93        title = _(u'Customer Id'),
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        )
130    phone = PhoneNumber(
131        title = _(u'Phone'),
132        description = u'',
133        required = False,
134        )
135
136    def setTempPassword(user, password):
137        """Set a temporary password (LDAP-compatible) SSHA encoded for
138        officers.
139
140        """
141
142    def getTempPassword():
143        """Check if a temporary password has been set and if it
144        is not expired.
145
146        Return the temporary password if valid,
147        None otherwise. Unset the temporary password if expired.
148        """
149
150
151class ICustomerUpdateByRegNo(ICustomer):
152    """Representation of a customer. Skip regular reg_number validation.
153
154    """
155    reg_number = schema.TextLine(
156        title = _(u'Registration Number'),
157        required = False,
158        )
159
160
161class ICSVCustomerExporter(ICSVExporter):
162    """A regular ICSVExporter that additionally supports exporting
163      data from a given customer object.
164    """
165    def get_filtered(site, **kw):
166        """Get a filtered set of customer.
167        """
168
169    def export_customer(customer, filepath=None):
170        """Export data for a given customer.
171        """
172
173    def export_filtered(site, filepath=None, **kw):
174        """Export filtered set of customers.
175        """
176
177
178class ICustomerRequestPW(IIkobaObject):
179    """Representation of a customer for first-time password request.
180
181    This interface is used when customers use the requestpw page to
182    login for the the first time.
183    """
184    number = schema.TextLine(
185        title = _(u'Registration Number'),
186        required = True,
187        )
188
189    firstname = schema.TextLine(
190        title = _(u'First Name'),
191        required = True,
192        )
193
194    email = schema.ASCIILine(
195        title = _(u'Email Address'),
196        required = True,
197        constraint=validate_email,
198        )
199
200
201class ICustomerCreate(IIkobaObject):
202    """Representation of an customer for account creation.
203
204    This interface is used when customers use the createaccount page.
205    """
206
207    firstname = schema.TextLine(
208        title = _(u'First Name'),
209        required = True,
210        )
211
212    middlename = schema.TextLine(
213        title = _(u'Middle Name'),
214        required = False,
215        )
216
217    lastname = schema.TextLine(
218        title = _(u'Last Name (Surname)'),
219        required = True,
220        )
221
222    email = schema.ASCIILine(
223        title = _(u'Email Address'),
224        required = True,
225        constraint=validate_email,
226        )
227
228
229# Customer document interfaces
230
231class ICustomerDocumentsContainer(IDocumentsContainer):
232    """A container for customer document objects.
233
234    """
235
236
237class ICustomerDocument(IDocument):
238    """A customer document object.
239
240    """
241
242    is_editable = Attribute('Document editable by customer')
243    translated_class_name = Attribute('Translatable class name')
244
245
246class ICustomerPDFDocument(IDocument):
247    """A customer document.
248
249    """
250
251# Customer contract interfaces
252
253class IContractsContainer(IIkobaObject):
254    """A container for customer aplication objects.
255
256    """
257
258    def addContract(contract):
259        """Add an contract object.
260        """
261
262
263class IContract(IIkobaObject):
264    """A customer contract.
265
266    """
267    contract_id = Attribute('Contract Identifier')
268    history = Attribute('Object history, a list of messages')
269    state = Attribute('Returns the contract state')
270    translated_state = Attribute(
271        'Returns a translated, more verbose appliction state')
272    class_name = Attribute('Name of the contract class')
273    formatted_transition_date = Attribute(
274        'Last transition formatted date string')
275    contract_category = Attribute('Category for the grouping of products')
276    last_product_id = Attribute(
277        'Id of product recently stored with the contract')
278    is_editable = Attribute('Document editable by customer')
279    translated_class_name = Attribute('Translatable class name')
280
281    title = schema.TextLine(
282        title = _(u'Contract Title'),
283        required = True,
284        )
285
286    last_transition_date = schema.Datetime(
287        title = _(u'Last Transition Date'),
288        required = False,
289        readonly = False,
290        )
291
292    product_object = schema.Choice(
293        title = _(u'Product'),
294        source = ConCatProductSource(),
295        required = False,
296        )
297
298
299class IContractEdit(IContract):
300    """Interface for editing contract data by customers.
301
302    """
303
304    product_object = schema.Choice(
305        title = _(u'Product'),
306        source = ConCatProductSource(),
307        required = True,
308        )
309
310
311class ISampleContract(IContract):
312    """A customer contract sample with document attached.
313
314    """
315
316    document_object = schema.Choice(
317        title = _(u'Document'),
318        source = CustomerDocumentSource(),
319        required = False,
320        )
321
322
323class ISampleContractEdit(ISampleContract):
324    """Interface for editing sample contract data by customers.
325
326    """
327
328    product_object = schema.Choice(
329        title = _(u'Product'),
330        source = ConCatProductSource(),
331        required = True,
332        )
333
334    document_object = schema.Choice(
335        title = _(u'Document'),
336        source = CustomerDocumentSource(),
337        required = True,
338        )
Note: See TracBrowser for help on using the repository browser.