source: main/kofacustom.wdu/trunk/src/kofacustom/wdu/applicants/browser.py @ 17977

Last change on this file since 17977 was 12888, checked in by Henrik Bettermann, 10 years ago

More fields and declarations.

  • Property svn:keywords set to Id
File size: 10.0 KB
RevLine 
[10765]1## $Id: browser.py 12888 2015-04-26 19:45:46Z 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"""
20import grok
[12885]21from zope.component import getUtility
22from zope.i18n import translate
23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
24from zope.formlib.textwidgets import BytesDisplayWidget
25from waeup.kofa.students.interfaces import IStudentsUtils
[10765]26from kofacustom.nigeria.applicants.browser import (
27    NigeriaApplicantDisplayFormPage,
[12885]28    NigeriaApplicantManageFormPage,
29    NigeriaApplicantEditFormPage,
[10765]30    NigeriaPDFApplicationSlip)
31
[12885]32from kofacustom.nigeria.applicants.interfaces import (
[12887]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    #PUTME_OMIT_DISPLAY_FIELDS,
39    #PUTME_OMIT_PDF_FIELDS,
40    #PUTME_OMIT_MANAGE_FIELDS,
41    #PUTME_OMIT_EDIT_FIELDS,
42    #PUTME_OMIT_RESULT_SLIP_FIELDS,
43    #PUDE_OMIT_DISPLAY_FIELDS,
44    #PUDE_OMIT_PDF_FIELDS,
45    #PUDE_OMIT_MANAGE_FIELDS,
46    #PUDE_OMIT_EDIT_FIELDS,
47    #PUDE_OMIT_RESULT_SLIP_FIELDS,
[12885]48    )
49
50from kofacustom.wdu.applicants.interfaces import (
51    ICustomUGApplicant,
52    ICustomUGApplicantEdit,
53    ICustomPUTMEApplicantEdit,
54    )
55
[11940]56from kofacustom.wdu.interfaces import MessageFactory as _
[10765]57
[12885]58
[12887]59# UG students are all undergraduate students.
60UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
61UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
62UG_OMIT_MANAGE_FIELDS = ('special_application',)
63UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
64    'student_id', 'notice',
65    'screening_score',
66    'screening_venue',
67    'screening_date',
68    #'jamb_age',
69    #'jamb_subjects',
70    #'jamb_score',
71    'aggregate')
72
73# PUTME is a subgroup of UG with the same interface.
74PUTME_OMIT_FIELDS = (
75    'hq_type',
76    'hq_matric_no',
77    'hq_degree',
78    'hq_school',
79    'hq_session',
80    'hq_disc',
81    )
82PUTME_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUTME_OMIT_FIELDS
83PUTME_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUTME_OMIT_FIELDS
84PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + (
85    #'firstname',
86    #'middlename',
87    #'lastname',
88    #'sex',
89    #'course1',
90    #'lga'
91    )
92PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + ('phone',)
93PUTME_OMIT_RESULT_SLIP_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + (
94    'phone',
95    'date_of_birth', 'sex',
96    'nationality', 'lga', #'perm_address',
97    'course2', 'screening_venue',
98    'screening_date')
99
100# PUDE is a subgroup of UG with the same interface.
101PUDE_OMIT_FIELDS = (
102    'jamb_subjects',
103    'jamb_score',
104    'jamb_age',
105    'aggregate')
106PUDE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUDE_OMIT_FIELDS
107PUDE_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUDE_OMIT_FIELDS
108PUDE_OMIT_EDIT_FIELDS = set(UG_OMIT_EDIT_FIELDS + PUDE_OMIT_FIELDS + (
109    #'firstname',
110    #'middlename',
111    #'lastname',
112    #'sex',
113    #'course1',
114    #'lga'
115    ))
116PUDE_OMIT_PDF_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + ('phone',)
117PUDE_OMIT_RESULT_SLIP_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + (
118    'phone',
119    'date_of_birth', 'sex',
120    'nationality', 'lga', #'perm_address',
121    'course2', 'screening_venue',
122    'screening_date')
123
124
[12885]125class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
126    """A display view for applicant data.
127    """
128
129    @property
130    def form_fields(self):
131        if self.target is not None and self.target.startswith('putme'):
132            form_fields = grok.AutoFields(ICustomUGApplicant)
133            for field in PUTME_OMIT_DISPLAY_FIELDS:
134                form_fields = form_fields.omit(field)
135        elif self.target is not None and self.target.startswith('pude'):
136            form_fields = grok.AutoFields(ICustomUGApplicant)
137            for field in PUDE_OMIT_DISPLAY_FIELDS:
138                form_fields = form_fields.omit(field)
139        else:
140            form_fields = grok.AutoFields(ICustomUGApplicant)
141            for field in UG_OMIT_DISPLAY_FIELDS:
142                form_fields = form_fields.omit(field)
143        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
144        form_fields['notice'].custom_widget = BytesDisplayWidget
145        if not getattr(self.context, 'student_id'):
146            form_fields = form_fields.omit('student_id')
147        if not getattr(self.context, 'screening_score'):
148            form_fields = form_fields.omit('screening_score')
149        if not getattr(self.context, 'screening_venue') or self._not_paid():
150            form_fields = form_fields.omit('screening_venue')
151        if not getattr(self.context, 'screening_date') or self._not_paid():
152            form_fields = form_fields.omit('screening_date')
153        return form_fields
154
155class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
156
157    @property
[12888]158    def note(self):
159        if self.context.sex == 'm':
160            pronoun = ('he', 'his', 'him')
161        else:
162            pronoun = ('she', 'her', 'her')
163        return ("<br /><br />The applicant has confirmed "
164                "that the passport photograph uploaded on this form is a true "
165                "picture of %s. The applicant also declared that, by submitting this form, %s wish to enter "
166                "Wester Delta University, Oghara, that the particulars given in this form are "
167                "to the best of %s knowledge and belief correct and that if admitted to the "
168                "university, %s shall regard %sself bound by the Ordinance Statutes and "
169                "Regulations of the University in so far as they affect %s. The applicant understands that "
170                "withholding any information requested or giving information may make %s "
171                "ineligable for admission, regsitration or matriculation, or compel %s "
172                "expulsion from the institution."
173                % (pronoun[2],
174                   pronoun[0],
175                   pronoun[1],
176                   pronoun[0],
177                   pronoun[2],
178                   pronoun[2],
179                   pronoun[2],
180                   pronoun[1])
181                )
182
183    @property
[12885]184    def form_fields(self):
185        if self.target is not None and self.target.startswith('putme'):
186            form_fields = grok.AutoFields(ICustomUGApplicant)
187            if self._reduced_slip():
188                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
189                    form_fields = form_fields.omit(field)
190            else:
191                for field in PUTME_OMIT_PDF_FIELDS:
192                    form_fields = form_fields.omit(field)
193        elif self.target is not None and self.target.startswith('pude'):
194            form_fields = grok.AutoFields(ICustomUGApplicant)
195            if self._reduced_slip():
196                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
197                    form_fields = form_fields.omit(field)
198            else:
199                for field in PUDE_OMIT_PDF_FIELDS:
200                    form_fields = form_fields.omit(field)
201        else:
202            form_fields = grok.AutoFields(ICustomUGApplicant)
203            for field in UG_OMIT_PDF_FIELDS:
204                form_fields = form_fields.omit(field)
205        if not getattr(self.context, 'student_id'):
206            form_fields = form_fields.omit('student_id')
207        if not getattr(self.context, 'screening_score'):
208            form_fields = form_fields.omit('screening_score')
209        if not getattr(self.context, 'screening_venue'):
210            form_fields = form_fields.omit('screening_venue')
211        if not getattr(self.context, 'screening_date'):
212            form_fields = form_fields.omit('screening_date')
213        return form_fields
214
215class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
216    """A full edit view for applicant data.
217    """
218
219    @property
220    def form_fields(self):
221        if self.target is not None and self.target.startswith('putme'):
222            form_fields = grok.AutoFields(ICustomUGApplicant)
223            for field in PUTME_OMIT_MANAGE_FIELDS:
224                form_fields = form_fields.omit(field)
225        elif self.target is not None and self.target.startswith('pude'):
226            form_fields = grok.AutoFields(ICustomUGApplicant)
227            for field in PUDE_OMIT_MANAGE_FIELDS:
228                form_fields = form_fields.omit(field)
229        else:
230            form_fields = grok.AutoFields(ICustomUGApplicant)
231            for field in UG_OMIT_MANAGE_FIELDS:
232                form_fields = form_fields.omit(field)
233        form_fields['student_id'].for_display = True
234        form_fields['applicant_id'].for_display = True
235        return form_fields
236
237class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
238    """An applicant-centered edit view for applicant data.
239    """
240
241    @property
242    def form_fields(self):
243        if self.target is not None and self.target.startswith('putme'):
244            form_fields = grok.AutoFields(ICustomPUTMEApplicantEdit)
245            for field in PUTME_OMIT_EDIT_FIELDS:
246                form_fields = form_fields.omit(field)
247        elif self.target is not None and self.target.startswith('pude'):
248            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
249            for field in PUDE_OMIT_EDIT_FIELDS:
250                form_fields = form_fields.omit(field)
251        else:
252            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
253            for field in UG_OMIT_EDIT_FIELDS:
254                form_fields = form_fields.omit(field)
255        form_fields['applicant_id'].for_display = True
256        form_fields['reg_number'].for_display = True
257        return form_fields
Note: See TracBrowser for help on using the repository browser.