## $Id: interfaces.py 12057 2014-11-25 13:15:27Z 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, application_sessions_vocab, 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) 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. """ def archive(id=None): """Create on-dist archive of customers. If id is `None`, all customers are archived. If id contains a single id string, only the respective customers are archived. If id contains a list of id strings all of the respective customers types are saved to disk. """ def clear(id=None, archive=True): """Remove customers of type given by 'id'. Optionally archive the customers. If id is `None`, all customers are archived. If id contains a single id string, only the respective customers are archived. If id contains a list of id strings all of the respective customer types are saved to disk. If `archive` is ``False`` none of the archive-handling is done and respective customers are simply removed from the database. """ 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. """ #is_editable = Attribute('Document editable by customer') #translated_class_name = Attribute('Translatable class name') class ICustomerPDFDocument(IDocument): """A customer document. """