source: main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/applicants/browser.py @ 14292

Last change on this file since 14292 was 14210, checked in by Henrik Bettermann, 8 years ago

Customize UG_OMIT lists.

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