1 | ## $Id: interfaces.py 10088 2013-04-22 05:20:58Z 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.students.vocabularies import nats_vocab |
---|
26 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
27 | LGASource, |
---|
28 | INigeriaUGApplicant, |
---|
29 | INigeriaApplicantOnlinePayment, |
---|
30 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
31 | INigeriaApplicantUpdateByRegNo, |
---|
32 | IPUTMEApplicantEdit, |
---|
33 | OMIT_DISPLAY_FIELDS, |
---|
34 | UG_OMIT_DISPLAY_FIELDS, |
---|
35 | UG_OMIT_PDF_FIELDS, |
---|
36 | UG_OMIT_MANAGE_FIELDS, |
---|
37 | UG_OMIT_EDIT_FIELDS, |
---|
38 | ) |
---|
39 | |
---|
40 | |
---|
41 | PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ('course2',) |
---|
42 | PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
43 | PG_OMIT_MANAGE_FIELDS = ('course2',) |
---|
44 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + ( |
---|
45 | 'student_id', 'notice', |
---|
46 | 'screening_score', 'screening_venue', |
---|
47 | 'screening_date',) |
---|
48 | |
---|
49 | from waeup.futminna.interfaces import MessageFactory as _ |
---|
50 | |
---|
51 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
52 | """An undergraduate applicant. |
---|
53 | |
---|
54 | This interface defines the least common multiple of all fields |
---|
55 | in ug application forms. In customized forms, fields can be excluded by |
---|
56 | adding them to the UG_OMIT* tuples. |
---|
57 | """ |
---|
58 | |
---|
59 | class ICustomPGApplicant(IApplicantBaseData): |
---|
60 | """A postgraduate applicant. |
---|
61 | |
---|
62 | This interface defines the least common multiple of all fields |
---|
63 | in pg application forms. In customized forms, fields can be excluded by |
---|
64 | adding them to the PG_OMIT* tuples. |
---|
65 | """ |
---|
66 | |
---|
67 | nationality = schema.Choice( |
---|
68 | source = nats_vocab, |
---|
69 | title = _(u'Nationality'), |
---|
70 | required = True, |
---|
71 | ) |
---|
72 | lga = schema.Choice( |
---|
73 | source = LGASource(), |
---|
74 | title = _(u'State/LGA (Nigerians only)'), |
---|
75 | required = False, |
---|
76 | ) |
---|
77 | perm_address = schema.Text( |
---|
78 | title = _(u'Permanent Address'), |
---|
79 | required = False, |
---|
80 | ) |
---|
81 | course1 = schema.Choice( |
---|
82 | title = _(u'Programme desired'), |
---|
83 | source = AppCatCertificateSource(), |
---|
84 | required = True, |
---|
85 | ) |
---|
86 | notice = schema.Text( |
---|
87 | title = _(u'Notice'), |
---|
88 | required = False, |
---|
89 | readonly = False, |
---|
90 | ) |
---|
91 | #screening_venue = schema.TextLine( |
---|
92 | # title = _(u'Screening Venue'), |
---|
93 | # required = False, |
---|
94 | # ) |
---|
95 | #screening_date = schema.TextLine( |
---|
96 | # title = _(u'Screening Date'), |
---|
97 | # required = False, |
---|
98 | # ) |
---|
99 | #screening_score = schema.Int( |
---|
100 | # title = _(u'Screening Score (%)'), |
---|
101 | # required = False, |
---|
102 | # ) |
---|
103 | student_id = schema.TextLine( |
---|
104 | title = _(u'Student Id'), |
---|
105 | required = False, |
---|
106 | readonly = False, |
---|
107 | ) |
---|
108 | course_admitted = schema.Choice( |
---|
109 | title = _(u'Admitted Course of Study'), |
---|
110 | source = CertificateSource(), |
---|
111 | required = False, |
---|
112 | readonly = False, |
---|
113 | ) |
---|
114 | locked = schema.Bool( |
---|
115 | title = _(u'Form locked'), |
---|
116 | default = False, |
---|
117 | ) |
---|
118 | |
---|
119 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
120 | """An interface for both types of applicants. |
---|
121 | |
---|
122 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
123 | by ICustomPGApplicant field settings. If a field is defined |
---|
124 | in both interfaces zope.schema validates only against the |
---|
125 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
126 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
127 | """ |
---|
128 | |
---|
129 | def writeLogMessage(view, comment): |
---|
130 | """Adds an INFO message to the log file |
---|
131 | """ |
---|
132 | |
---|
133 | def createStudent(): |
---|
134 | """Create a student object from applicatnt data |
---|
135 | and copy applicant object. |
---|
136 | """ |
---|
137 | |
---|
138 | class ICustomUGApplicantEdit(INigeriaUGApplicantEdit): |
---|
139 | """An undergraduate applicant interface for edit forms. |
---|
140 | |
---|
141 | Here we can repeat the fields from base data and set the |
---|
142 | `required` and `readonly` attributes to True to further restrict |
---|
143 | the data access. Or we can allow only certain certificates to be |
---|
144 | selected by choosing the appropriate source. |
---|
145 | |
---|
146 | We cannot omit fields here. This has to be done in the |
---|
147 | respective form page. |
---|
148 | """ |
---|
149 | |
---|
150 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
151 | """A postgraduate applicant interface for editing. |
---|
152 | |
---|
153 | Here we can repeat the fields from base data and set the |
---|
154 | `required` and `readonly` attributes to True to further restrict |
---|
155 | the data access. Or we can allow only certain certificates to be |
---|
156 | selected by choosing the appropriate source. |
---|
157 | |
---|
158 | We cannot omit fields here. This has to be done in the |
---|
159 | respective form page. |
---|
160 | """ |
---|
161 | |
---|
162 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
163 | """An applicant payment via payment gateways. |
---|
164 | |
---|
165 | """ |
---|
166 | |
---|
167 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
168 | """An undergraduate applicant interface for editing. |
---|
169 | |
---|
170 | Here we can repeat the fields from base data and set the |
---|
171 | `required` and `readonly` attributes to True to further restrict |
---|
172 | the data access. Or we can allow only certain certificates to be |
---|
173 | selected by choosing the appropriate source. |
---|
174 | |
---|
175 | We cannot omit fields here. This has to be done in the |
---|
176 | respective form page. |
---|
177 | """ |
---|
178 | |
---|
179 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
180 | """Representation of an applicant. |
---|
181 | |
---|
182 | Skip regular reg_number validation if reg_number is used for finding |
---|
183 | the applicant object. |
---|
184 | """ |
---|
185 | |
---|