source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py @ 13814

Last change on this file since 13814 was 13814, checked in by Henrik Bettermann, 9 years ago

Define IUnibenRegistration for ICTWK registrations and implement RegTypesSource?.

  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1# -*- coding: utf-8 -*-
2## $Id: interfaces.py 13814 2016-04-07 14:21:25Z henrik $
3##
4## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
5## This program is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18##
19"""Customized interfaces of the university application package.
20"""
21
22from zope import schema
23from zc.sourcefactory.basic import BasicSourceFactory
24from waeup.kofa.applicants.interfaces import (
25    IApplicantBaseData,
26    AppCatCertificateSource, CertificateSource)
27from waeup.kofa.schoolgrades import ResultEntryField
28from waeup.kofa.interfaces import (
29    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
30    IKofaObject, ContextualDictSourceFactoryBase)
31from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
42from waeup.uniben.interfaces import MessageFactory as _
43from waeup.uniben.payments.interfaces import ICustomOnlinePayment
44
45
46REGISTRATION_CATS = {
47    'corporate': ('Corporate Registration', 250000, 1),
48    'group': ('Group Registration', 200000, 2),
49    'individual': ('Individual Registration', 45000, 3),
50    'student': ('Student Registration', 5000, 4),
51    'fullpage': ('Full Page', 250000, 5),
52    'halfpage': ('Half Page', 150000, 6),
53    'quarterpage': ('Quarter Page', 100000, 7),
54    }
55
56class RegTypesSource(BasicSourceFactory):
57    """A source that delivers all kinds of registrations.
58    """
59    def getValues(self):
60        sorted_items = sorted(REGISTRATION_CATS.items(),
61                              key=lambda element: element[1][2])
62        return [item[0] for item in sorted_items]
63
64    def getTitle(self, value):
65        return u"%s @ ₦ %s" % (
66            REGISTRATION_CATS[value][0],
67            REGISTRATION_CATS[value][1])
68
69class IUnibenRegistration(IKofaObject):
70    """A Uniben registrant.
71    """
72
73    suspended = schema.Bool(
74        title = _(u'Account suspended'),
75        default = False,
76        required = False,
77        )
78
79    locked = schema.Bool(
80        title = _(u'Form locked'),
81        default = False,
82        required = False,
83        )
84
85    applicant_id = schema.TextLine(
86        title = _(u'Registrant Id'),
87        required = False,
88        readonly = False,
89        )
90
91    firstname = schema.TextLine(
92        title = _(u'First Name'),
93        required = True,
94        )
95
96    middlename = schema.TextLine(
97        title = _(u'Middle Name'),
98        required = False,
99        )
100
101    lastname = schema.TextLine(
102        title = _(u'Last Name (Surname)'),
103        required = True,
104        )
105
106    #matric_number = schema.TextLine(
107    #    title = _(u'Matriculation Number'),
108    #    readonly = False,
109    #    required = False,
110    #    )
111
112    date_of_birth = FormattedDate(
113        title = _(u'Date of Birth'),
114        required = False,
115        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
116        show_year = True,
117        )
118
119    place_of_birth = schema.TextLine(
120        title = _(u'Place of Birth'),
121        readonly = False,
122        required = False,
123        )
124
125    nationality = schema.Choice(
126        vocabulary = nats_vocab,
127        title = _(u'Nationality'),
128        required = False,
129        )
130
131    email = schema.ASCIILine(
132        title = _(u'Email Address'),
133        required = True,
134        constraint=validate_email,
135        )
136
137    phone = PhoneNumber(
138        title = _(u'Phone'),
139        description = u'',
140        required = False,
141        )
142
143    perm_address = schema.Text(
144        title = _(u'Current Local Address'),
145        required = False,
146        readonly = False,
147        )
148
149    registration_cats = schema.List(
150        title = _(u'Registration Categories'),
151        value_type = schema.Choice(source=RegTypesSource()),
152        required = True,
153        default = [],
154        )
155
156
157
158class ICustomUGApplicant(INigeriaUGApplicant):
159    """An undergraduate applicant.
160
161    This interface defines the least common multiple of all fields
162    in ug application forms. In customized forms, fields can be excluded by
163    adding them to the UG_OMIT* tuples.
164    """
165
166class ICustomPGApplicant(INigeriaPGApplicant):
167    """A postgraduate applicant.
168
169    This interface defines the least common multiple of all fields
170    in pg application forms. In customized forms, fields can be excluded by
171    adding them to the PG_OMIT* tuples.
172    """
173
174
175class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
176    IUnibenRegistration):
177    """An interface for both types of applicants.
178
179    Attention: The ICustomPGApplicant field seetings will be overwritten
180    by ICustomPGApplicant field settings. If a field is defined
181    in both interfaces zope.schema validates only against the
182    constraints in ICustomUGApplicant. This does not affect the forms
183    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
184    """
185
186    def writeLogMessage(view, comment):
187        """Adds an INFO message to the log file
188        """
189
190    def createStudent():
191        """Create a student object from applicant data
192        and copy applicant object.
193        """
194
195class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
196    """An undergraduate applicant interface for edit forms.
197
198    Here we can repeat the fields from base data and set the
199    `required` and `readonly` attributes to True to further restrict
200    the data access. Or we can allow only certain certificates to be
201    selected by choosing the appropriate source.
202
203    We cannot omit fields here. This has to be done in the
204    respective form page.
205    """
206
207class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
208    """A postgraduate applicant interface for editing.
209
210    Here we can repeat the fields from base data and set the
211    `required` and `readonly` attributes to True to further restrict
212    the data access. Or we can allow only certain certificates to be
213    selected by choosing the appropriate source.
214
215    We cannot omit fields here. This has to be done in the
216    respective form page.
217    """
218
219
220class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
221    """An applicant payment via payment gateways.
222
223    """
224
225class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
226    """An undergraduate applicant interface for editing.
227
228    Here we can repeat the fields from base data and set the
229    `required` and `readonly` attributes to True to further restrict
230    the data access. Or we can allow only certain certificates to be
231    selected by choosing the appropriate source.
232
233    We cannot omit fields here. This has to be done in the
234    respective form page.
235    """
236
237class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
238    """Representation of an applicant.
239
240    Skip regular reg_number validation if reg_number is used for finding
241    the applicant object.
242    """
Note: See TracBrowser for help on using the repository browser.