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

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

Adjust registration forms. Add localization.

  • Property svn:keywords set to Id
File size: 5.9 KB
RevLine 
[10765]1## $Id: interfaces.py 11843 2014-10-14 17:45:38Z 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"""
[11843]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)
[10765]40from waeup.kofa.applicants.interfaces import (
[11843]41    contextual_reg_num_source, AppCatCertificateSource,
42    IApplicantOnlinePayment)
[11832]43from kofacustom.pcn.interfaces import MessageFactory as _
[10765]44
[11843]45class ICustomApplicant(IApplicantBase):
46    """The data for an applicant.
[10765]47
[11843]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.
[10765]52    """
53
[11843]54    def writeLogMessage(view, comment):
55        """Adds an INFO message to the log file
56        """
57
58    def createStudent():
59        """Create a student object from applicatnt data
60        and copy applicant object.
61        """
62
63    history = Attribute('Object history, a list of messages')
64    state = Attribute('The application state of an applicant')
65    display_fullname = Attribute('The fullname of an applicant')
66    application_date = Attribute('UTC datetime of submission, used for export only')
67    password = Attribute('Encrypted password of a applicant')
68    application_number = Attribute('The key under which the record is stored')
69
70    suspended = schema.Bool(
71        title = _(u'Account suspended'),
72        default = False,
73        required = False,
74        )
75
76    applicant_id = schema.TextLine(
77        title = _(u'Applicant Id'),
78        required = False,
79        readonly = False,
80        )
81    reg_number = TextLineChoice(
82        title = _(u'Registration Number'),
83        readonly = False,
84        required = True,
85        source = contextual_reg_num_source,
86        )
87    firstname = schema.TextLine(
88        title = _(u'First Name'),
89        required = True,
90        )
91    middlename = schema.TextLine(
92        title = _(u'Middle Name'),
93        required = False,
94        )
95    lastname = schema.TextLine(
96        title = _(u'Last Name (Surname)'),
97        required = True,
98        )
99    date_of_birth = FormattedDate(
100        title = _(u'Date of Birth'),
101        required = False,
102        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
103        show_year = True,
104        )
105    sex = schema.Choice(
106        title = _(u'Sex'),
107        source = GenderSource(),
108        required = True,
109        )
110    email = schema.ASCIILine(
111        title = _(u'Email Address'),
112        required = False,
113        constraint=validate_email,
114        )
115    phone = PhoneNumber(
116        title = _(u'Phone'),
117        description = u'',
118        required = False,
119        )
120    course1 = schema.Choice(
121        title = _(u'1st Choice Course of Study'),
122        source = AppCatCertificateSource(),
123        required = True,
124        )
125
126    notice = schema.Text(
127        title = _(u'Notice'),
128        required = False,
129        )
130
131    course_admitted = schema.Choice(
132        title = _(u'Admitted Course of Study'),
133        source = CertificateSource(),
134        required = False,
135        )
136    locked = schema.Bool(
137        title = _(u'Form locked'),
138        default = False,
139        required = False,
140        )
141
142class ICustomApplicantEdit(ICustomApplicant):
[11687]143    """A custom applicant interface for editing.
[10765]144
145    Here we can repeat the fields from base data and set the
146    `required` and `readonly` attributes to True to further restrict
147    the data access. Or we can allow only certain certificates to be
148    selected by choosing the appropriate source.
149
150    We cannot omit fields here. This has to be done in the
151    respective form page.
[11843]152
[10765]153    """
154
[11843]155    email = schema.ASCIILine(
156        title = _(u'Email Address'),
157        required = True,
158        constraint=validate_email,
159        )
160    course1 = schema.Choice(
161        title = _(u'1st Choice Course of Study'),
162        source = AppCatCertificateSource(),
163        required = True,
164        )
165    course_admitted = schema.Choice(
166        title = _(u'Admitted Course of Study'),
167        source = CertificateSource(),
168        required = False,
169        readonly = True,
170        )
171    notice = schema.Text(
172        title = _(u'Notice'),
173        required = False,
174        readonly = True,
175        )
176
[11687]177class ICustomApplicantOnlinePayment(IApplicantOnlinePayment):
178    """A custom applicant payment via payment gateways.
[10765]179
180    """
181
Note: See TracBrowser for help on using the repository browser.