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

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

Exchange city and lga.

  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1# -*- coding: utf-8 -*-
2## $Id: interfaces.py 13828 2016-04-11 09:14:35Z 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 Advert', 250000, 5),
52    'halfpage': ('Half Page Advert', 150000, 6),
53    'quarterpage': ('Quarter Page Advert', 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    sex = schema.Choice(
107        title = _(u'Sex'),
108        source = GenderSource(),
109        required = True,
110        )
111
112    nationality = schema.Choice(
113        vocabulary = nats_vocab,
114        title = _(u'Nationality'),
115        required = False,
116        )
117
118    email = schema.ASCIILine(
119        title = _(u'Email Address'),
120        required = True,
121        constraint=validate_email,
122        )
123
124    phone = PhoneNumber(
125        title = _(u'Phone'),
126        description = u'',
127        required = False,
128        )
129
130    #perm_address = schema.Text(
131    #    title = _(u'Current Local Address'),
132    #    required = False,
133    #    readonly = False,
134    #    )
135
136    institution = schema.TextLine(
137        title = _(u'Institution/Organisation'),
138        required = False,
139        readonly = False,
140        )
141
142    city = schema.TextLine(
143        title = _(u'City'),
144        required = False,
145        readonly = False,
146        )
147
148    lga = schema.Choice(
149        source = LGASource(),
150        title = _(u'State/LGA'),
151        required = False,
152        )
153
154    registration_cats = schema.List(
155        title = _(u'Registration Categories'),
156        value_type = schema.Choice(source=RegTypesSource()),
157        required = True,
158        default = [],
159        )
160
161
162
163class ICustomUGApplicant(INigeriaUGApplicant):
164    """An undergraduate applicant.
165
166    This interface defines the least common multiple of all fields
167    in ug application forms. In customized forms, fields can be excluded by
168    adding them to the UG_OMIT* tuples.
169    """
170
171class ICustomPGApplicant(INigeriaPGApplicant):
172    """A postgraduate applicant.
173
174    This interface defines the least common multiple of all fields
175    in pg application forms. In customized forms, fields can be excluded by
176    adding them to the PG_OMIT* tuples.
177    """
178
179
180class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
181    IUnibenRegistration):
182    """An interface for both types of applicants.
183
184    Attention: The ICustomPGApplicant field seetings will be overwritten
185    by ICustomPGApplicant field settings. If a field is defined
186    in both interfaces zope.schema validates only against the
187    constraints in ICustomUGApplicant. This does not affect the forms
188    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
189    """
190
191    def writeLogMessage(view, comment):
192        """Adds an INFO message to the log file
193        """
194
195    def createStudent():
196        """Create a student object from applicant data
197        and copy applicant object.
198        """
199
200class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
201    """An undergraduate applicant interface for edit forms.
202
203    Here we can repeat the fields from base data and set the
204    `required` and `readonly` attributes to True to further restrict
205    the data access. Or we can allow only certain certificates to be
206    selected by choosing the appropriate source.
207
208    We cannot omit fields here. This has to be done in the
209    respective form page.
210    """
211
212class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
213    """A postgraduate applicant interface for editing.
214
215    Here we can repeat the fields from base data and set the
216    `required` and `readonly` attributes to True to further restrict
217    the data access. Or we can allow only certain certificates to be
218    selected by choosing the appropriate source.
219
220    We cannot omit fields here. This has to be done in the
221    respective form page.
222    """
223
224
225class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
226    """An applicant payment via payment gateways.
227
228    """
229
230class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
231    """An undergraduate applicant interface for editing.
232
233    Here we can repeat the fields from base data and set the
234    `required` and `readonly` attributes to True to further restrict
235    the data access. Or we can allow only certain certificates to be
236    selected by choosing the appropriate source.
237
238    We cannot omit fields here. This has to be done in the
239    respective form page.
240    """
241
242class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
243    """Representation of an applicant.
244
245    Skip regular reg_number validation if reg_number is used for finding
246    the applicant object.
247    """
Note: See TracBrowser for help on using the repository browser.