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

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

Let's take the 'last transition date' from the history. Saving the date is redundant.

  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1## $Id: interfaces.py 12210 2014-12-13 08:58:43Z 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_by_customer = Attribute('Document editable by customer')
243    is_editable_by_manager = Attribute('Document editable by manager')
244    translated_class_name = Attribute('Translatable class name')
245
246
247class ICustomerPDFDocument(IDocument):
248    """A customer document.
249
250    """
251
252# Customer contract interfaces
253
254class IContractsContainer(IIkobaObject):
255    """A container for customer aplication objects.
256
257    """
258
259    def addContract(contract):
260        """Add an contract object.
261        """
262
263
264class IContract(IIkobaObject):
265    """A customer contract.
266
267    """
268    contract_id = Attribute('Contract Identifier')
269    history = Attribute('Object history, a list of messages')
270    state = Attribute('Returns the contract state')
271    translated_state = Attribute(
272        'Returns a translated, more verbose appliction state')
273    class_name = Attribute('Name of the contract class')
274    formatted_transition_date = Attribute(
275        'Last transition formatted date string')
276    contract_category = Attribute('Category for the grouping of products')
277    last_product_id = Attribute(
278        'Id of product recently stored with the contract')
279    is_editable_by_customer = Attribute('Contract editable by customer')
280    is_approvable = Attribute('Contract approvable by officer')
281    translated_class_name = Attribute('Translatable class name')
282
283    title = schema.TextLine(
284        title = _(u'Contract Title'),
285        required = True,
286        )
287
288    product_object = schema.Choice(
289        title = _(u'Product'),
290        source = ConCatProductSource(),
291        required = False,
292        )
293
294
295class IContractEdit(IContract):
296    """Interface for editing contract data by customers.
297
298    """
299
300    product_object = schema.Choice(
301        title = _(u'Product'),
302        source = ConCatProductSource(),
303        required = True,
304        )
305
306
307class ISampleContract(IContract):
308    """A customer contract sample with document attached.
309
310    """
311
312    document_object = schema.Choice(
313        title = _(u'Document'),
314        source = CustomerDocumentSource(),
315        required = False,
316        )
317
318
319class ISampleContractEdit(ISampleContract):
320    """Interface for editing sample contract data by customers.
321
322    """
323
324    product_object = schema.Choice(
325        title = _(u'Product'),
326        source = ConCatProductSource(),
327        required = True,
328        )
329
330    document_object = schema.Choice(
331        title = _(u'Document'),
332        source = CustomerDocumentSource(),
333        required = True,
334        )
Note: See TracBrowser for help on using the repository browser.