1 | ## $Id: browser.py 15087 2018-07-12 07:33:18Z 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 | """UI components for basic applicants and related components. |
---|
19 | """ |
---|
20 | import grok |
---|
21 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
22 | from waeup.kofa.applicants.browser import ( |
---|
23 | ApplicantRegistrationPage, ApplicantsContainerPage) |
---|
24 | from kofacustom.nigeria.applicants.browser import ( |
---|
25 | NigeriaApplicantDisplayFormPage, |
---|
26 | NigeriaPDFApplicationSlip, |
---|
27 | NigeriaApplicantManageFormPage, |
---|
28 | NigeriaApplicantEditFormPage) |
---|
29 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
30 | UG_OMIT_DISPLAY_FIELDS, |
---|
31 | UG_OMIT_PDF_FIELDS, |
---|
32 | UG_OMIT_MANAGE_FIELDS, |
---|
33 | UG_OMIT_EDIT_FIELDS, |
---|
34 | PG_OMIT_DISPLAY_FIELDS, |
---|
35 | PG_OMIT_PDF_FIELDS, |
---|
36 | PG_OMIT_MANAGE_FIELDS, |
---|
37 | PG_OMIT_EDIT_FIELDS, |
---|
38 | ) |
---|
39 | from kofacustom.edopoly.applicants.interfaces import ( |
---|
40 | ICustomUGApplicantEdit, ICustomUGApplicant, |
---|
41 | ICustomPGApplicantEdit, ICustomPGApplicant) |
---|
42 | |
---|
43 | from kofacustom.edopoly.interfaces import MessageFactory as _ |
---|
44 | |
---|
45 | # Fields to be omitted in all display forms. course_admitted is |
---|
46 | # rendered separately. |
---|
47 | |
---|
48 | OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', |
---|
49 | 'result_uploaded', 'suspended', 'special_application', |
---|
50 | 'bank_account_number', |
---|
51 | 'bank_account_name', |
---|
52 | 'bank_name') |
---|
53 | |
---|
54 | # UG students are all undergraduate students. |
---|
55 | UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
56 | 'jamb_subjects_list', 'programme_type') |
---|
57 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
58 | UG_OMIT_MANAGE_FIELDS = ( |
---|
59 | 'special_application', |
---|
60 | 'jamb_subjects_list', |
---|
61 | 'programme_type') |
---|
62 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
63 | 'student_id', |
---|
64 | 'notice', |
---|
65 | 'screening_score', |
---|
66 | 'screening_venue', |
---|
67 | 'screening_date', |
---|
68 | # 'jamb_age', |
---|
69 | # 'jamb_subjects', |
---|
70 | # 'jamb_score', |
---|
71 | # 'jamb_reg_number', |
---|
72 | 'aggregate') |
---|
73 | |
---|
74 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
75 | """A display view for applicant data. |
---|
76 | """ |
---|
77 | |
---|
78 | @property |
---|
79 | def form_fields(self): |
---|
80 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
81 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
82 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
83 | form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget |
---|
84 | if not getattr(self.context, 'student_id'): |
---|
85 | form_fields = form_fields.omit('student_id') |
---|
86 | if not getattr(self.context, 'screening_score'): |
---|
87 | form_fields = form_fields.omit('screening_score') |
---|
88 | if not getattr(self.context, 'screening_venue'): |
---|
89 | form_fields = form_fields.omit('screening_venue') |
---|
90 | if not getattr(self.context, 'screening_date'): |
---|
91 | form_fields = form_fields.omit('screening_date') |
---|
92 | return form_fields |
---|
93 | |
---|
94 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
95 | |
---|
96 | @property |
---|
97 | def form_fields(self): |
---|
98 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
99 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
100 | for field in UG_OMIT_PDF_FIELDS: |
---|
101 | form_fields = form_fields.omit(field) |
---|
102 | if not getattr(self.context, 'student_id'): |
---|
103 | form_fields = form_fields.omit('student_id') |
---|
104 | if not getattr(self.context, 'screening_score'): |
---|
105 | form_fields = form_fields.omit('screening_score') |
---|
106 | if not getattr(self.context, 'screening_venue'): |
---|
107 | form_fields = form_fields.omit('screening_venue') |
---|
108 | if not getattr(self.context, 'screening_date'): |
---|
109 | form_fields = form_fields.omit('screening_date') |
---|
110 | return form_fields |
---|
111 | |
---|
112 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
113 | """A full edit view for applicant data. |
---|
114 | """ |
---|
115 | |
---|
116 | @property |
---|
117 | def form_fields(self): |
---|
118 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
119 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
120 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
121 | form_fields = form_fields.omit(field) |
---|
122 | form_fields['student_id'].for_display = True |
---|
123 | form_fields['applicant_id'].for_display = True |
---|
124 | return form_fields |
---|
125 | |
---|
126 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
127 | """An applicant-centered edit view for applicant data. |
---|
128 | """ |
---|
129 | |
---|
130 | @property |
---|
131 | def form_fields(self): |
---|
132 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
133 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
134 | for field in UG_OMIT_EDIT_FIELDS: |
---|
135 | form_fields = form_fields.omit(field) |
---|
136 | form_fields['applicant_id'].for_display = True |
---|
137 | form_fields['reg_number'].for_display = True |
---|
138 | return form_fields |
---|