## $Id: interfaces.py 12234 2014-12-14 21:48:41Z henrik $ ## ## Copyright (C) 2011 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 ## """Customized interfaces of the university application package. """ from datetime import datetime from grokcore.content.interfaces import IContainer from zc.sourcefactory.contextual import BasicContextualSourceFactory from zope import schema from zope.component import queryUtility, getUtility from zope.catalog.interfaces import ICatalog from zope.interface import Interface, Attribute, implements, directlyProvides from zope.schema.interfaces import ( ValidationError, ISource, IContextSourceBinder) from waeup.kofa.browser.interfaces import IApplicantBase from waeup.kofa.schema import TextLineChoice, FormattedDate from waeup.kofa.interfaces import ( IKofaObject, validate_email, SimpleKofaVocabulary) from waeup.kofa.interfaces import MessageFactory as _ from waeup.kofa.payments.interfaces import IOnlinePayment from waeup.kofa.schema import PhoneNumber from waeup.kofa.students.vocabularies import GenderSource, RegNumberSource from waeup.kofa.university.vocabularies import ( AppCatSource, CertificateSource, SpecialApplicationSource) from waeup.kofa.applicants.interfaces import ( contextual_reg_num_source, AppCatCertificateSource, IApplicantOnlinePayment) from kofacustom.pcn.interfaces import MessageFactory as _ class ICustomApplicant(IApplicantBase): """The data for an applicant. This is a base interface with no field required. For use with processors, forms, etc., please use one of the derived interfaces below, which set more fields to required state, depending on use-case. """ history = Attribute('Object history, a list of messages') state = Attribute('The application state of an applicant') display_fullname = Attribute('The fullname of an applicant') application_date = Attribute('UTC datetime of submission, used for export only') password = Attribute('Encrypted password of a applicant') application_number = Attribute('The key under which the record is stored') suspended = schema.Bool( title = _(u'Account suspended'), default = False, required = False, ) applicant_id = schema.TextLine( title = _(u'Applicant Id'), required = False, readonly = False, ) reg_number = TextLineChoice( title = _(u'Registration Number'), readonly = False, required = True, source = contextual_reg_num_source, ) 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, ) date_of_birth = FormattedDate( title = _(u'Date of Birth'), required = False, #date_format = u'%d/%m/%Y', # Use grok-instance-wide default show_year = True, ) sex = schema.Choice( title = _(u'Sex'), source = GenderSource(), required = True, ) email = schema.ASCIILine( title = _(u'Email Address'), required = False, constraint=validate_email, ) phone = PhoneNumber( title = _(u'Phone'), description = u'', required = False, ) course1 = schema.Choice( title = _(u'1st Choice Course of Study'), source = AppCatCertificateSource(), required = True, ) notice = schema.Text( title = _(u'Notice'), required = False, ) course_admitted = schema.Choice( title = _(u'Admitted Course of Study'), source = CertificateSource(), required = False, ) locked = schema.Bool( title = _(u'Form locked'), default = False, required = False, ) class ICustomApplicantEdit(ICustomApplicant): """A custom applicant interface for editing. Here we can repeat the fields from base data and set the `required` and `readonly` attributes to True to further restrict the data access. Or we can allow only certain certificates to be selected by choosing the appropriate source. We cannot omit fields here. This has to be done in the respective form page. """ email = schema.ASCIILine( title = _(u'Email Address'), required = True, constraint=validate_email, ) course1 = schema.Choice( title = _(u'1st Choice Course of Study'), source = AppCatCertificateSource(), required = True, ) course_admitted = schema.Choice( title = _(u'Admitted Course of Study'), source = CertificateSource(), required = False, readonly = True, ) notice = schema.Text( title = _(u'Notice'), required = False, readonly = True, ) class ICustomApplicantOnlinePayment(IApplicantOnlinePayment): """A custom applicant payment via payment gateways. """