## $Id: interfaces.py 12119 2014-12-02 14:38:31Z henrik $ ## ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## #from datetime import datetime from zope.component import getUtility from zope.interface import Attribute, Interface from zope import schema from zc.sourcefactory.contextual import BasicContextualSourceFactory from waeup.ikoba.interfaces import MessageFactory as _ from waeup.ikoba.interfaces import ( IIkobaObject, validate_email, ICSVExporter) from waeup.ikoba.schema import TextLineChoice, FormattedDate, PhoneNumber from waeup.ikoba.browser.interfaces import ICustomerNavigationBase from waeup.ikoba.documents.interfaces import IDocumentsContainer, IDocument from waeup.ikoba.customers.vocabularies import ( contextual_reg_num_source, GenderSource, nats_vocab, ConCatProductSource, CustomerDocumentSource) class ICustomersUtils(Interface): """A collection of methods which are subject to customization. """ class ICustomersContainer(IIkobaObject): """A customers container contains company customers. """ def addCustomer(customer): """Add an ICustomer object and subcontainers. """ unique_customer_id = Attribute("""A unique customer id.""") class ICustomerNavigation(ICustomerNavigationBase): """Interface needed for custom navigation, logging, etc. """ customer = Attribute('Customer object of context.') def writeLogMessage(view, message): """Write a view specific log message into custom.log. """ class ICustomer(IIkobaObject): """Representation of a customer. """ history = Attribute('Object history, a list of messages') state = Attribute('Returns the registration state of a customer') password = Attribute('Encrypted password of a customer') temp_password = Attribute( 'Dictionary with user name, timestamp and encrypted password') fullname = Attribute('All name parts separated by hyphens') display_fullname = Attribute('The fullname of an applicant') suspended = schema.Bool( title = _(u'Account suspended'), default = False, required = False, ) suspended_comment = schema.Text( title = _(u"Reasons for Deactivation"), required = False, description = _( u'This message will be shown if and only if deactivated ' 'customers try to login.'), ) customer_id = schema.TextLine( title = _(u'Customer Id'), required = False, ) firstname = schema.TextLine( title = _(u'First Name'), required = True, ) middlename = schema.TextLine( title = _(u'Middle Name'), required = False, ) lastname = schema.TextLine( title = _(u'Last Name (Surname)'), required = True, ) sex = schema.Choice( title = _(u'Sex'), source = GenderSource(), required = True, ) reg_number = TextLineChoice( title = _(u'Registration Number'), required = True, readonly = False, source = contextual_reg_num_source, ) email = schema.ASCIILine( title = _(u'Email'), required = False, constraint=validate_email, ) phone = PhoneNumber( title = _(u'Phone'), description = u'', required = False, ) def setTempPassword(user, password): """Set a temporary password (LDAP-compatible) SSHA encoded for officers. """ def getTempPassword(): """Check if a temporary password has been set and if it is not expired. Return the temporary password if valid, None otherwise. Unset the temporary password if expired. """ class ICustomerUpdateByRegNo(ICustomer): """Representation of a customer. Skip regular reg_number validation. """ reg_number = schema.TextLine( title = _(u'Registration Number'), required = False, ) class ICSVCustomerExporter(ICSVExporter): """A regular ICSVExporter that additionally supports exporting data from a given customer object. """ def get_filtered(site, **kw): """Get a filtered set of customer. """ def export_customer(customer, filepath=None): """Export data for a given customer. """ def export_filtered(site, filepath=None, **kw): """Export filtered set of customers. """ class ICustomerRequestPW(IIkobaObject): """Representation of a customer for first-time password request. This interface is used when customers use the requestpw page to login for the the first time. """ number = schema.TextLine( title = _(u'Registration Number'), required = True, ) firstname = schema.TextLine( title = _(u'First Name'), required = True, ) email = schema.ASCIILine( title = _(u'Email Address'), required = True, constraint=validate_email, ) class ICustomerCreate(IIkobaObject): """Representation of an customer for account creation. This interface is used when customers use the createaccount page. """ firstname = schema.TextLine( title = _(u'First Name'), required = True, ) middlename = schema.TextLine( title = _(u'Middle Name'), required = False, ) lastname = schema.TextLine( title = _(u'Last Name (Surname)'), required = True, ) email = schema.ASCIILine( title = _(u'Email Address'), required = True, constraint=validate_email, ) # Customer document interfaces class ICustomerDocumentsContainer(IDocumentsContainer): """A container for customer document objects. """ class ICustomerDocument(IDocument): """A customer document object. """ is_editable = Attribute('Document editable by customer') translated_class_name = Attribute('Translatable class name') class ICustomerPDFDocument(IDocument): """A customer document. """ # Customer contract interfaces class IContractsContainer(IIkobaObject): """A container for customer aplication objects. """ def addContract(contract): """Add an contract object. """ class IContract(IIkobaObject): """A customer contract. """ contract_id = Attribute('Contract Identifier') history = Attribute('Object history, a list of messages') state = Attribute('Returns the contract state') translated_state = Attribute( 'Returns a translated, more verbose appliction state') class_name = Attribute('Name of the contract class') formatted_transition_date = Attribute( 'Last transition formatted date string') contract_category = Attribute('Category for the grouping of products') last_product_id = Attribute( 'Id of product recently stored with the contract') title = schema.TextLine( title = _(u'Contract Title'), required = True, ) last_transition_date = schema.Datetime( title = _(u'Last Transition Date'), required = False, readonly = False, ) product_object = schema.Choice( title = _(u'Product'), source = ConCatProductSource(), required = False, ) class IContractEdit(IContract): """Interface for editing contract data by customers. """ product_object = schema.Choice( title = _(u'Product'), source = ConCatProductSource(), required = True, ) class ISampleContract(IContract): """A customer contract sample with document attached. """ document_object = schema.Choice( title = _(u'Document'), source = CustomerDocumentSource(), required = False, ) class ISampleContractEdit(ISampleContract): """Interface for editing sample contract data by customers. """ product_object = schema.Choice( title = _(u'Product'), source = ConCatProductSource(), required = True, ) document_object = schema.Choice( title = _(u'Document'), source = CustomerDocumentSource(), required = True, )