1 | ## $Id: browser.py 14128 2016-08-24 12:30:11Z 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 | NigeriaApplicantManageFormPage, |
---|
27 | NigeriaApplicantEditFormPage, |
---|
28 | NigeriaPDFApplicationSlip) |
---|
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 | ) |
---|
35 | from kofacustom.coewarri.applicants.interfaces import ( |
---|
36 | ICustomUGApplicantEdit, ICustomUGApplicant) |
---|
37 | from kofacustom.coewarri.interfaces import MessageFactory as _ |
---|
38 | |
---|
39 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
40 | """A display view for applicant data. |
---|
41 | """ |
---|
42 | |
---|
43 | @property |
---|
44 | def form_fields(self): |
---|
45 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
46 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
47 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
48 | form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget |
---|
49 | if not getattr(self.context, 'student_id'): |
---|
50 | form_fields = form_fields.omit('student_id') |
---|
51 | if not getattr(self.context, 'screening_score'): |
---|
52 | form_fields = form_fields.omit('screening_score') |
---|
53 | if not getattr(self.context, 'screening_venue'): |
---|
54 | form_fields = form_fields.omit('screening_venue') |
---|
55 | if not getattr(self.context, 'screening_date'): |
---|
56 | form_fields = form_fields.omit('screening_date') |
---|
57 | return form_fields |
---|
58 | |
---|
59 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
60 | |
---|
61 | @property |
---|
62 | def form_fields(self): |
---|
63 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
64 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
65 | for field in UG_OMIT_PDF_FIELDS: |
---|
66 | form_fields = form_fields.omit(field) |
---|
67 | if not getattr(self.context, 'student_id'): |
---|
68 | form_fields = form_fields.omit('student_id') |
---|
69 | if not getattr(self.context, 'screening_score'): |
---|
70 | form_fields = form_fields.omit('screening_score') |
---|
71 | if not getattr(self.context, 'screening_venue'): |
---|
72 | form_fields = form_fields.omit('screening_venue') |
---|
73 | if not getattr(self.context, 'screening_date'): |
---|
74 | form_fields = form_fields.omit('screening_date') |
---|
75 | return form_fields |
---|
76 | |
---|
77 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
78 | """A full edit view for applicant data. |
---|
79 | """ |
---|
80 | |
---|
81 | @property |
---|
82 | def form_fields(self): |
---|
83 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
84 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
85 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
86 | form_fields = form_fields.omit(field) |
---|
87 | form_fields['student_id'].for_display = True |
---|
88 | form_fields['applicant_id'].for_display = True |
---|
89 | return form_fields |
---|
90 | |
---|
91 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
92 | """An applicant-centered edit view for applicant data. |
---|
93 | """ |
---|
94 | |
---|
95 | @property |
---|
96 | def form_fields(self): |
---|
97 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
98 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
99 | for field in UG_OMIT_EDIT_FIELDS: |
---|
100 | form_fields = form_fields.omit(field) |
---|
101 | form_fields['applicant_id'].for_display = True |
---|
102 | form_fields['reg_number'].for_display = True |
---|
103 | return form_fields |
---|
104 | |
---|