source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/browser.py @ 10532

Last change on this file since 10532 was 10529, checked in by Henrik Bettermann, 12 years ago

Add note on payment slips.

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1## $Id: browser.py 10529 2013-08-23 10:38:21Z 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.component import getUtility
22from zope.i18n import translate
23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
24from zope.formlib.textwidgets import BytesDisplayWidget
25from waeup.kofa.applicants.viewlets import (
26    PaymentReceiptActionButton, PDFActionButton)
27from waeup.kofa.applicants.pdf import PDFApplicationSlip
28
29from kofacustom.nigeria.applicants.browser import (
30    NigeriaExportPDFPaymentSlipPage, NigeriaApplicantManageFormPage,
31    NigeriaApplicantDisplayFormPage, NigeriaApplicantEditFormPage)
32
33from kofacustom.nigeria.applicants.interfaces import (
34    UG_OMIT_DISPLAY_FIELDS,
35    UG_OMIT_PDF_FIELDS,
36    UG_OMIT_MANAGE_FIELDS,
37    UG_OMIT_EDIT_FIELDS
38    )
39from waeup.fceokene.applicants.interfaces import (
40    ICustomUGApplicant, ICustomUGApplicantEdit,
41    BEC_OMIT_DISPLAY_FIELDS,
42    BEC_OMIT_PDF_FIELDS,
43    BEC_OMIT_MANAGE_FIELDS,
44    BEC_OMIT_EDIT_FIELDS
45    )
46
47class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
48    """A display view for applicant data.
49    """
50
51    @property
52    def form_fields(self):
53        target = getattr(self.context.__parent__, 'prefix', None)
54        form_fields = grok.AutoFields(ICustomUGApplicant)
55        if target is not None and target.startswith('bec'):
56            for field in BEC_OMIT_DISPLAY_FIELDS:
57                form_fields = form_fields.omit(field)
58        else:
59            form_fields = grok.AutoFields(ICustomUGApplicant)
60            for field in UG_OMIT_DISPLAY_FIELDS:
61                form_fields = form_fields.omit(field)
62        form_fields['notice'].custom_widget = BytesDisplayWidget
63        if not getattr(self.context, 'student_id'):
64            form_fields = form_fields.omit('student_id')
65        if not getattr(self.context, 'screening_score'):
66            form_fields = form_fields.omit('screening_score')
67        if not getattr(self.context, 'screening_venue'):
68            form_fields = form_fields.omit('screening_venue')
69        if not getattr(self.context, 'screening_date'):
70            form_fields = form_fields.omit('screening_date')
71        return form_fields
72
73class CustomPDFApplicationSlip(PDFApplicationSlip):
74
75    def _reduced_slip(self):
76        return getattr(self.context, 'result_uploaded', False)
77
78    @property
79    def form_fields(self):
80        target = getattr(self.context.__parent__, 'prefix', None)
81        form_fields = grok.AutoFields(ICustomUGApplicant)
82        if target is not None and target.startswith('bec'):
83            for field in BEC_OMIT_PDF_FIELDS:
84                form_fields = form_fields.omit(field)
85        else:
86            form_fields = grok.AutoFields(ICustomUGApplicant)
87            for field in UG_OMIT_PDF_FIELDS:
88                form_fields = form_fields.omit(field)
89        if not getattr(self.context, 'student_id'):
90            form_fields = form_fields.omit('student_id')
91        if not getattr(self.context, 'screening_score'):
92            form_fields = form_fields.omit('screening_score')
93        if not getattr(self.context, 'screening_venue'):
94            form_fields = form_fields.omit('screening_venue')
95        if not getattr(self.context, 'screening_date'):
96            form_fields = form_fields.omit('screening_date')
97        return form_fields
98
99class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
100    """Deliver a PDF slip of the context.
101    """
102
103    note = '''
104
105
106The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
107'''
108
109class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
110    """A full edit view for applicant data.
111    """
112   
113    @property
114    def form_fields(self):
115        target = getattr(self.context.__parent__, 'prefix', None)
116        form_fields = grok.AutoFields(ICustomUGApplicant)
117        if target is not None and target.startswith('bec'):
118            for field in BEC_OMIT_MANAGE_FIELDS:
119                form_fields = form_fields.omit(field)
120        else:
121            for field in UG_OMIT_MANAGE_FIELDS:
122                form_fields = form_fields.omit(field)
123        form_fields['student_id'].for_display = True
124        form_fields['applicant_id'].for_display = True
125        return form_fields
126
127class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
128    """An applicant-centered edit view for applicant data.
129    """
130
131    @property
132    def form_fields(self):
133        target = getattr(self.context.__parent__, 'prefix', None)
134        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
135        if target is not None and target.startswith('bec'):
136            for field in BEC_OMIT_EDIT_FIELDS:
137                form_fields = form_fields.omit(field)
138        else:
139            for field in UG_OMIT_EDIT_FIELDS:
140                form_fields = form_fields.omit(field)
141        form_fields['applicant_id'].for_display = True
142        form_fields['reg_number'].for_display = True
143        return form_fields
Note: See TracBrowser for help on using the repository browser.