source: main/kofacustom.pcn/trunk/src/kofacustom/pcn/applicants/interfaces.py

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

Repair package. Hopefully we'll never need this package.

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1## $Id: interfaces.py 12234 2014-12-14 21:48:41Z henrik $
2##
3## Copyright (C) 2011 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"""Customized interfaces of the university application package.
19"""
20from datetime import datetime
21from grokcore.content.interfaces import IContainer
22from zc.sourcefactory.contextual import BasicContextualSourceFactory
23from zope import schema
24from zope.component import queryUtility, getUtility
25from zope.catalog.interfaces import ICatalog
26from zope.interface import Interface, Attribute, implements, directlyProvides
27from zope.schema.interfaces import (
28    ValidationError, ISource, IContextSourceBinder)
29from waeup.kofa.browser.interfaces import IApplicantBase
30from waeup.kofa.schema import TextLineChoice, FormattedDate
31from waeup.kofa.interfaces import (
32    IKofaObject, validate_email,
33    SimpleKofaVocabulary)
34from waeup.kofa.interfaces import MessageFactory as _
35from waeup.kofa.payments.interfaces import IOnlinePayment
36from waeup.kofa.schema import PhoneNumber
37from waeup.kofa.students.vocabularies import GenderSource, RegNumberSource
38from waeup.kofa.university.vocabularies import (
39    AppCatSource, CertificateSource, SpecialApplicationSource)
40from waeup.kofa.applicants.interfaces import (
41    contextual_reg_num_source, AppCatCertificateSource,
42    IApplicantOnlinePayment)
43from kofacustom.pcn.interfaces import MessageFactory as _
44
45class ICustomApplicant(IApplicantBase):
46    """The data for an applicant.
47
48    This is a base interface with no field
49    required. For use with processors, forms, etc., please use one of
50    the derived interfaces below, which set more fields to required
51    state, depending on use-case.
52    """
53
54    history = Attribute('Object history, a list of messages')
55    state = Attribute('The application state of an applicant')
56    display_fullname = Attribute('The fullname of an applicant')
57    application_date = Attribute('UTC datetime of submission, used for export only')
58    password = Attribute('Encrypted password of a applicant')
59    application_number = Attribute('The key under which the record is stored')
60
61    suspended = schema.Bool(
62        title = _(u'Account suspended'),
63        default = False,
64        required = False,
65        )
66
67    applicant_id = schema.TextLine(
68        title = _(u'Applicant Id'),
69        required = False,
70        readonly = False,
71        )
72    reg_number = TextLineChoice(
73        title = _(u'Registration Number'),
74        readonly = False,
75        required = True,
76        source = contextual_reg_num_source,
77        )
78    firstname = schema.TextLine(
79        title = _(u'First Name'),
80        required = True,
81        )
82    middlename = schema.TextLine(
83        title = _(u'Middle Name'),
84        required = False,
85        )
86    lastname = schema.TextLine(
87        title = _(u'Last Name (Surname)'),
88        required = True,
89        )
90    date_of_birth = FormattedDate(
91        title = _(u'Date of Birth'),
92        required = False,
93        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
94        show_year = True,
95        )
96    sex = schema.Choice(
97        title = _(u'Sex'),
98        source = GenderSource(),
99        required = True,
100        )
101    email = schema.ASCIILine(
102        title = _(u'Email Address'),
103        required = False,
104        constraint=validate_email,
105        )
106    phone = PhoneNumber(
107        title = _(u'Phone'),
108        description = u'',
109        required = False,
110        )
111    course1 = schema.Choice(
112        title = _(u'1st Choice Course of Study'),
113        source = AppCatCertificateSource(),
114        required = True,
115        )
116
117    notice = schema.Text(
118        title = _(u'Notice'),
119        required = False,
120        )
121
122    course_admitted = schema.Choice(
123        title = _(u'Admitted Course of Study'),
124        source = CertificateSource(),
125        required = False,
126        )
127    locked = schema.Bool(
128        title = _(u'Form locked'),
129        default = False,
130        required = False,
131        )
132
133class ICustomApplicantEdit(ICustomApplicant):
134    """A custom applicant interface for editing.
135
136    Here we can repeat the fields from base data and set the
137    `required` and `readonly` attributes to True to further restrict
138    the data access. Or we can allow only certain certificates to be
139    selected by choosing the appropriate source.
140
141    We cannot omit fields here. This has to be done in the
142    respective form page.
143
144    """
145
146    email = schema.ASCIILine(
147        title = _(u'Email Address'),
148        required = True,
149        constraint=validate_email,
150        )
151    course1 = schema.Choice(
152        title = _(u'1st Choice Course of Study'),
153        source = AppCatCertificateSource(),
154        required = True,
155        )
156    course_admitted = schema.Choice(
157        title = _(u'Admitted Course of Study'),
158        source = CertificateSource(),
159        required = False,
160        readonly = True,
161        )
162    notice = schema.Text(
163        title = _(u'Notice'),
164        required = False,
165        readonly = True,
166        )
167
168class ICustomApplicantOnlinePayment(IApplicantOnlinePayment):
169    """A custom applicant payment via payment gateways.
170
171    """
172
Note: See TracBrowser for help on using the repository browser.