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

Last change on this file since 17367 was 15895, checked in by Henrik Bettermann, 5 years ago

Omit UG_OMIT_DISPLAY_FIELDS.

  • Property svn:keywords set to Id
File size: 5.0 KB
RevLine 
[10765]1## $Id: browser.py 15895 2019-12-18 12:39:45Z 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
[14128]21from zope.formlib.textwidgets import BytesDisplayWidget
[10765]22from waeup.kofa.applicants.browser import (
23    ApplicantRegistrationPage, ApplicantsContainerPage)
24from kofacustom.nigeria.applicants.browser import (
25    NigeriaApplicantDisplayFormPage,
[14128]26    NigeriaApplicantManageFormPage,
27    NigeriaApplicantEditFormPage,
[10765]28    NigeriaPDFApplicationSlip)
[14210]29
[14128]30from kofacustom.coewarri.applicants.interfaces import (
31    ICustomUGApplicantEdit, ICustomUGApplicant)
[14035]32from kofacustom.coewarri.interfaces import MessageFactory as _
[10765]33
[14210]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
[14128]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)
[15895]71        for field in UG_OMIT_DISPLAY_FIELDS:
72            form_fields = form_fields.omit(field)
[14128]73        form_fields['notice'].custom_widget = BytesDisplayWidget
74        form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget
75        if not getattr(self.context, 'student_id'):
76            form_fields = form_fields.omit('student_id')
77        if not getattr(self.context, 'screening_score'):
78            form_fields = form_fields.omit('screening_score')
79        if not getattr(self.context, 'screening_venue'):
80            form_fields = form_fields.omit('screening_venue')
81        if not getattr(self.context, 'screening_date'):
82            form_fields = form_fields.omit('screening_date')
83        return form_fields
84
85class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
86
87    @property
88    def form_fields(self):
89        target = getattr(self.context.__parent__, 'prefix', None)
90        form_fields = grok.AutoFields(ICustomUGApplicant)
91        for field in UG_OMIT_PDF_FIELDS:
92            form_fields = form_fields.omit(field)
93        if not getattr(self.context, 'student_id'):
94            form_fields = form_fields.omit('student_id')
95        if not getattr(self.context, 'screening_score'):
96            form_fields = form_fields.omit('screening_score')
97        if not getattr(self.context, 'screening_venue'):
98            form_fields = form_fields.omit('screening_venue')
99        if not getattr(self.context, 'screening_date'):
100            form_fields = form_fields.omit('screening_date')
101        return form_fields
102
103class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
104    """A full edit view for applicant data.
105    """
106
107    @property
108    def form_fields(self):
109        target = getattr(self.context.__parent__, 'prefix', None)
110        form_fields = grok.AutoFields(ICustomUGApplicant)
111        for field in UG_OMIT_MANAGE_FIELDS:
112            form_fields = form_fields.omit(field)
113        form_fields['student_id'].for_display = True
114        form_fields['applicant_id'].for_display = True
115        return form_fields
116
117class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
118    """An applicant-centered edit view for applicant data.
119    """
120
121    @property
122    def form_fields(self):
123        target = getattr(self.context.__parent__, 'prefix', None)
124        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
125        for field in UG_OMIT_EDIT_FIELDS:
126            form_fields = form_fields.omit(field)
127        form_fields['applicant_id'].for_display = True
128        form_fields['reg_number'].for_display = True
129        return form_fields
130
Note: See TracBrowser for help on using the repository browser.