1 | ## $Id: interfaces.py 15809 2019-11-15 07:28:55Z 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 | """ |
---|
20 | |
---|
21 | from zope import schema |
---|
22 | from waeup.kofa.applicants.interfaces import ( |
---|
23 | IApplicantBaseData, |
---|
24 | AppCatCertificateSource, CertificateSource) |
---|
25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
26 | from waeup.kofa.interfaces import ( |
---|
27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
28 | from waeup.kofa.schema import FormattedDate, TextLineChoice |
---|
29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
30 | from waeup.kofa.applicants.interfaces import ( |
---|
31 | contextual_reg_num_source, IApplicantBaseData) |
---|
32 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
33 | LGASource, high_qual, high_grade, exam_types, |
---|
34 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
35 | INigeriaApplicantOnlinePayment, |
---|
36 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
37 | INigeriaApplicantUpdateByRegNo, |
---|
38 | IPUTMEApplicantEdit, |
---|
39 | ) |
---|
40 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
41 | from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment |
---|
42 | |
---|
43 | sponsors_vocab = SimpleKofaVocabulary( |
---|
44 | (_('Bauchi Government'), 'bauchi'), |
---|
45 | (_('Company'), 'company'), |
---|
46 | (_('Federal Government (Amnesty)'), 'federalgov'), |
---|
47 | (_('Dangote Group'), 'dangote'), |
---|
48 | (_('Kano Government'), 'kano'), |
---|
49 | (_('Parent/Guardian'), 'parent'), |
---|
50 | (_('Rosula Organization'), 'rosula'), |
---|
51 | (_('Self'), 'self'), |
---|
52 | (_('Social Impact Project'), 'social'), |
---|
53 | ) |
---|
54 | |
---|
55 | heard_about_types_vocab = SimpleKofaVocabulary( |
---|
56 | (_('Facebook/Twitter/Other Social Media'), 'socmedia'), |
---|
57 | (_('From a Friend'), 'friend'), |
---|
58 | (_('Newspaper Advertisement'), 'newspaper'), |
---|
59 | (_('Radio Advertisement'), 'radio'), |
---|
60 | (_('Television Advertisement'), 'television'), |
---|
61 | ) |
---|
62 | |
---|
63 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
64 | """An undergraduate applicant. |
---|
65 | |
---|
66 | This interface defines the least common multiple of all fields |
---|
67 | in ug application forms. In customized forms, fields can be excluded by |
---|
68 | adding them to the UG_OMIT* tuples. |
---|
69 | """ |
---|
70 | |
---|
71 | sponsor = schema.Choice( |
---|
72 | title = _(u'Sponsor'), |
---|
73 | vocabulary = sponsors_vocab, |
---|
74 | required = False, |
---|
75 | ) |
---|
76 | |
---|
77 | heard_about = schema.Choice( |
---|
78 | title = _(u'How did you hear about IU?'), |
---|
79 | vocabulary = heard_about_types_vocab, |
---|
80 | required = False, |
---|
81 | ) |
---|
82 | |
---|
83 | ICustomUGApplicant[ |
---|
84 | 'sponsor'].order = ICustomUGApplicant['lga'].order |
---|
85 | ICustomUGApplicant[ |
---|
86 | 'heard_about'].order = ICustomUGApplicant['lga'].order |
---|
87 | ICustomUGApplicant[ |
---|
88 | 'sponsor'].order = ICustomUGApplicant['lga'].order |
---|
89 | ICustomUGApplicant[ |
---|
90 | 'lga'].order = ICustomUGApplicant['nationality'].order |
---|
91 | |
---|
92 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
93 | """A postgraduate applicant. |
---|
94 | |
---|
95 | This interface defines the least common multiple of all fields |
---|
96 | in pg application forms. In customized forms, fields can be excluded by |
---|
97 | adding them to the PG_OMIT* tuples. |
---|
98 | """ |
---|
99 | |
---|
100 | sponsor = schema.Choice( |
---|
101 | title = _(u'Sponsor'), |
---|
102 | vocabulary = sponsors_vocab, |
---|
103 | required = False, |
---|
104 | ) |
---|
105 | |
---|
106 | heard_about = schema.Choice( |
---|
107 | title = _(u'How did you hear about IU?'), |
---|
108 | vocabulary = heard_about_types_vocab, |
---|
109 | required = False, |
---|
110 | ) |
---|
111 | |
---|
112 | ICustomPGApplicant[ |
---|
113 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
114 | ICustomPGApplicant[ |
---|
115 | 'heard_about'].order = ICustomPGApplicant['lga'].order |
---|
116 | ICustomPGApplicant[ |
---|
117 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
118 | ICustomPGApplicant[ |
---|
119 | 'lga'].order = ICustomPGApplicant['nationality'].order |
---|
120 | |
---|
121 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
122 | """An interface for both types of applicants. |
---|
123 | |
---|
124 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
125 | by ICustomPGApplicant field settings. If a field is defined |
---|
126 | in both interfaces zope.schema validates only against the |
---|
127 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
128 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
129 | """ |
---|
130 | |
---|
131 | def writeLogMessage(view, comment): |
---|
132 | """Adds an INFO message to the log file |
---|
133 | """ |
---|
134 | |
---|
135 | def createStudent(): |
---|
136 | """Create a student object from applicant data |
---|
137 | and copy applicant object. |
---|
138 | """ |
---|
139 | |
---|
140 | class ICustomUGApplicantEdit(INigeriaUGApplicantEdit): |
---|
141 | """An undergraduate applicant interface for edit forms. |
---|
142 | |
---|
143 | Here we can repeat the fields from base data and set the |
---|
144 | `required` and `readonly` attributes to True to further restrict |
---|
145 | the data access. Or we can allow only certain certificates to be |
---|
146 | selected by choosing the appropriate source. |
---|
147 | |
---|
148 | We cannot omit fields here. This has to be done in the |
---|
149 | respective form page. |
---|
150 | """ |
---|
151 | |
---|
152 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
153 | """A postgraduate applicant interface for editing. |
---|
154 | |
---|
155 | Here we can repeat the fields from base data and set the |
---|
156 | `required` and `readonly` attributes to True to further restrict |
---|
157 | the data access. Or we can allow only certain certificates to be |
---|
158 | selected by choosing the appropriate source. |
---|
159 | |
---|
160 | We cannot omit fields here. This has to be done in the |
---|
161 | respective form page. |
---|
162 | """ |
---|
163 | |
---|
164 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
165 | """An applicant payment via payment gateways. |
---|
166 | |
---|
167 | """ |
---|
168 | |
---|
169 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
170 | """An undergraduate applicant interface for editing. |
---|
171 | |
---|
172 | Here we can repeat the fields from base data and set the |
---|
173 | `required` and `readonly` attributes to True to further restrict |
---|
174 | the data access. Or we can allow only certain certificates to be |
---|
175 | selected by choosing the appropriate source. |
---|
176 | |
---|
177 | We cannot omit fields here. This has to be done in the |
---|
178 | respective form page. |
---|
179 | """ |
---|
180 | |
---|
181 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
182 | """Representation of an applicant. |
---|
183 | |
---|
184 | Skip regular reg_number validation if reg_number is used for finding |
---|
185 | the applicant object. |
---|
186 | """ |
---|