1 | ## $Id: interfaces.py 15807 2019-11-14 14:45:16Z 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 | |
---|
101 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
102 | """An interface for both types of applicants. |
---|
103 | |
---|
104 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
105 | by ICustomPGApplicant field settings. If a field is defined |
---|
106 | in both interfaces zope.schema validates only against the |
---|
107 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
108 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
109 | """ |
---|
110 | |
---|
111 | def writeLogMessage(view, comment): |
---|
112 | """Adds an INFO message to the log file |
---|
113 | """ |
---|
114 | |
---|
115 | def createStudent(): |
---|
116 | """Create a student object from applicant data |
---|
117 | and copy applicant object. |
---|
118 | """ |
---|
119 | |
---|
120 | class ICustomUGApplicantEdit(INigeriaUGApplicantEdit): |
---|
121 | """An undergraduate applicant interface for edit forms. |
---|
122 | |
---|
123 | Here we can repeat the fields from base data and set the |
---|
124 | `required` and `readonly` attributes to True to further restrict |
---|
125 | the data access. Or we can allow only certain certificates to be |
---|
126 | selected by choosing the appropriate source. |
---|
127 | |
---|
128 | We cannot omit fields here. This has to be done in the |
---|
129 | respective form page. |
---|
130 | """ |
---|
131 | |
---|
132 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
133 | """A postgraduate applicant interface for editing. |
---|
134 | |
---|
135 | Here we can repeat the fields from base data and set the |
---|
136 | `required` and `readonly` attributes to True to further restrict |
---|
137 | the data access. Or we can allow only certain certificates to be |
---|
138 | selected by choosing the appropriate source. |
---|
139 | |
---|
140 | We cannot omit fields here. This has to be done in the |
---|
141 | respective form page. |
---|
142 | """ |
---|
143 | |
---|
144 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
145 | """An applicant payment via payment gateways. |
---|
146 | |
---|
147 | """ |
---|
148 | |
---|
149 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
150 | """An undergraduate applicant interface for editing. |
---|
151 | |
---|
152 | Here we can repeat the fields from base data and set the |
---|
153 | `required` and `readonly` attributes to True to further restrict |
---|
154 | the data access. Or we can allow only certain certificates to be |
---|
155 | selected by choosing the appropriate source. |
---|
156 | |
---|
157 | We cannot omit fields here. This has to be done in the |
---|
158 | respective form page. |
---|
159 | """ |
---|
160 | |
---|
161 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
162 | """Representation of an applicant. |
---|
163 | |
---|
164 | Skip regular reg_number validation if reg_number is used for finding |
---|
165 | the applicant object. |
---|
166 | """ |
---|