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

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

Add property attribute is_approvable.

  • Property svn:keywords set to Id
File size: 8.9 KB
RevLine 
[12018]1## $Id: interfaces.py 12144 2014-12-04 18:10:11Z 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 (
[12097]25    IIkobaObject, validate_email, ICSVExporter)
[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        )
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
[11985]150
[11958]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
[11985]160
[11958]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
[11967]169    def export_customer(customer, filepath=None):
[11958]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
[11985]177
[12039]178class ICustomerRequestPW(IIkobaObject):
179    """Representation of a customer for first-time password request.
[11967]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        )
[11989]199
200
[12039]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
[11989]229# Customer document interfaces
230
231class ICustomerDocumentsContainer(IDocumentsContainer):
232    """A container for customer document objects.
233
234    """
235
236
237class ICustomerDocument(IDocument):
[12089]238    """A customer document object.
[11989]239
240    """
241
[12089]242    is_editable = Attribute('Document editable by customer')
243    translated_class_name = Attribute('Translatable class name')
[12053]244
245
246class ICustomerPDFDocument(IDocument):
247    """A customer document.
248
[12089]249    """
250
[12097]251# Customer contract interfaces
[12089]252
[12097]253class IContractsContainer(IIkobaObject):
[12089]254    """A container for customer aplication objects.
255
256    """
257
[12097]258    def addContract(contract):
259        """Add an contract object.
[12089]260        """
261
262
[12097]263class IContract(IIkobaObject):
264    """A customer contract.
[12089]265
266    """
[12097]267    contract_id = Attribute('Contract Identifier')
[12089]268    history = Attribute('Object history, a list of messages')
[12097]269    state = Attribute('Returns the contract state')
[12089]270    translated_state = Attribute(
271        'Returns a translated, more verbose appliction state')
[12097]272    class_name = Attribute('Name of the contract class')
[12092]273    formatted_transition_date = Attribute(
274        'Last transition formatted date string')
[12097]275    contract_category = Attribute('Category for the grouping of products')
[12094]276    last_product_id = Attribute(
[12097]277        'Id of product recently stored with the contract')
[12144]278    is_editable = Attribute('Contract editable by customer')
279    is_approvable = Attribute('Contract approvable by officer')
[12143]280    translated_class_name = Attribute('Translatable class name')
[12089]281
282    title = schema.TextLine(
[12097]283        title = _(u'Contract Title'),
[12089]284        required = True,
285        )
286
287    last_transition_date = schema.Datetime(
288        title = _(u'Last Transition Date'),
289        required = False,
290        readonly = False,
291        )
[12092]292
[12119]293    product_object = schema.Choice(
[12092]294        title = _(u'Product'),
[12098]295        source = ConCatProductSource(),
[12095]296        required = False,
297        )
298
[12103]299
[12097]300class IContractEdit(IContract):
301    """Interface for editing contract data by customers.
[12095]302
303    """
304
[12119]305    product_object = schema.Choice(
[12095]306        title = _(u'Product'),
[12098]307        source = ConCatProductSource(),
[12094]308        required = True,
[12103]309        )
310
311
312class ISampleContract(IContract):
313    """A customer contract sample with document attached.
314
315    """
316
[12119]317    document_object = schema.Choice(
[12103]318        title = _(u'Document'),
319        source = CustomerDocumentSource(),
320        required = False,
321        )
322
323
324class ISampleContractEdit(ISampleContract):
325    """Interface for editing sample contract data by customers.
326
327    """
328
[12119]329    product_object = schema.Choice(
[12103]330        title = _(u'Product'),
331        source = ConCatProductSource(),
332        required = True,
333        )
334
[12119]335    document_object = schema.Choice(
[12103]336        title = _(u'Document'),
337        source = CustomerDocumentSource(),
338        required = True,
[12095]339        )
Note: See TracBrowser for help on using the repository browser.