source: main/kofacustom.edocons/trunk/src/kofacustom/edocons/applicants/browser.py @ 16644

Last change on this file since 16644 was 16643, checked in by Henrik Bettermann, 3 years ago

Remove course1 and course2.

  • Property svn:keywords set to Id
File size: 6.8 KB
RevLine 
[16639]1## $Id: browser.py 16643 2021-09-27 06:17:08Z henrik $
[15614]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
[16618]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
26from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
27    ApplicantManageFormPage, ApplicantEditFormPage,
28    ApplicantRegistrationPage,
29    OnlinePaymentDisplayFormPage,
30    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
31    )
32from waeup.kofa.applicants.viewlets import (
33    PDFActionButton, PaymentReceiptActionButton)
34from waeup.kofa.applicants.pdf import PDFApplicationSlip
[15614]35from kofacustom.nigeria.applicants.browser import (
36    NigeriaApplicantDisplayFormPage,
[16618]37    NigeriaApplicantManageFormPage,
38    NigeriaApplicantEditFormPage,
[15614]39    NigeriaPDFApplicationSlip)
[16618]40from kofacustom.nigeria.applicants.interfaces import (
41    INigeriaPGApplicant, INigeriaUGApplicant,
42    INigeriaPGApplicantEdit, INigeriaUGApplicantEdit,
43    INigeriaApplicantOnlinePayment,
[16643]44    #UG_OMIT_DISPLAY_FIELDS,
45    #UG_OMIT_PDF_FIELDS,
46    #UG_OMIT_MANAGE_FIELDS,
47    #UG_OMIT_EDIT_FIELDS,
[16618]48    PG_OMIT_DISPLAY_FIELDS,
49    PG_OMIT_PDF_FIELDS,
50    PG_OMIT_MANAGE_FIELDS,
51    PG_OMIT_EDIT_FIELDS,
52    )
53from kofacustom.edocons.applicants.interfaces import (
54    ICustomPGApplicant, ICustomUGApplicant, ICustomApplicant,
55    ICustomPGApplicantEdit, ICustomUGApplicantEdit,
56    ICustomApplicantOnlinePayment,
57    )
58from kofacustom.nigeria.interfaces import MessageFactory as _
[15614]59
[16643]60# Fields to be omitted in all display forms. course_admitted is
61# rendered separately.
62
63OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted',
64    'result_uploaded', 'suspended', 'special_application',
65    'bank_account_number',
66    'bank_account_name',
67    'bank_name',
68    'course1', 'course2') # these 2 have been added
69
70# UG students are all undergraduate students.
71UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
72    'jamb_subjects_list', 'programme_type')
73UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
74UG_OMIT_MANAGE_FIELDS = (
75    'special_application',
76    'jamb_subjects_list',
77    'programme_type')
78UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
79    'student_id',
80    'notice',
81    'screening_score',
82    'screening_venue',
83    'screening_date',
84    'jamb_age',
85    'jamb_subjects',
86    'jamb_score',
87    'jamb_reg_number',
88    'aggregate')
89
[16618]90class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
91    """A display view for applicant data.
92    """
[15614]93
[16618]94    @property
95    def form_fields(self):
96        if self.target is not None and self.target.startswith('pg'):
97            form_fields = grok.AutoFields(ICustomPGApplicant)
98            for field in PG_OMIT_DISPLAY_FIELDS:
99                form_fields = form_fields.omit(field)
100        else:
101            form_fields = grok.AutoFields(ICustomUGApplicant)
102            for field in UG_OMIT_DISPLAY_FIELDS:
103                form_fields = form_fields.omit(field)
104        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
105        form_fields['notice'].custom_widget = BytesDisplayWidget
106        if not getattr(self.context, 'student_id'):
107            form_fields = form_fields.omit('student_id')
108        if not getattr(self.context, 'screening_score'):
109            form_fields = form_fields.omit('screening_score')
110        if not getattr(self.context, 'screening_venue') or self._not_paid():
111            form_fields = form_fields.omit('screening_venue')
112        if not getattr(self.context, 'screening_date') or self._not_paid():
113            form_fields = form_fields.omit('screening_date')
114        return form_fields
115
116class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
117
118    @property
119    def form_fields(self):
120        if self.target is not None and self.target.startswith('pg'):
121            form_fields = grok.AutoFields(ICustomPGApplicant)
122            for field in PG_OMIT_PDF_FIELDS:
123                form_fields = form_fields.omit(field)
124        else:
125            form_fields = grok.AutoFields(ICustomUGApplicant)
126            for field in UG_OMIT_PDF_FIELDS:
127                form_fields = form_fields.omit(field)
128        if not getattr(self.context, 'student_id'):
129            form_fields = form_fields.omit('student_id')
130        if not getattr(self.context, 'screening_score'):
131            form_fields = form_fields.omit('screening_score')
132        if not getattr(self.context, 'screening_venue'):
133            form_fields = form_fields.omit('screening_venue')
134        if not getattr(self.context, 'screening_date'):
135            form_fields = form_fields.omit('screening_date')
136        return form_fields
137
138class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
139    """A full edit view for applicant data.
140    """
141
142    @property
143    def form_fields(self):
144        if self.target is not None and self.target.startswith('pg'):
145            form_fields = grok.AutoFields(ICustomPGApplicant)
146            for field in PG_OMIT_MANAGE_FIELDS:
147                form_fields = form_fields.omit(field)
148        else:
149            form_fields = grok.AutoFields(ICustomUGApplicant)
150            for field in UG_OMIT_MANAGE_FIELDS:
151                form_fields = form_fields.omit(field)
152        form_fields['student_id'].for_display = True
153        form_fields['applicant_id'].for_display = True
154        return form_fields
155
156class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
157    """An applicant-centered edit view for applicant data.
158    """
159
160    @property
161    def form_fields(self):
162        if self.target is not None and self.target.startswith('pg'):
163            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
164            for field in PG_OMIT_EDIT_FIELDS:
165                form_fields = form_fields.omit(field)
166        else:
167            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
168            for field in UG_OMIT_EDIT_FIELDS:
169                form_fields = form_fields.omit(field)
170        form_fields['applicant_id'].for_display = True
171        form_fields['reg_number'].for_display = True
172        return form_fields
Note: See TracBrowser for help on using the repository browser.