source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py @ 8065

Last change on this file since 8065 was 8053, checked in by Henrik Bettermann, 13 years ago

Derive IPGApplicant and IUGApplicant from IApplicantBaseData and not from IApplicant. We'll need this for the customized exporter.

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1## $Id: browser.py 8053 2012-04-06 16:01:57Z 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 waeup.kofa.widgets.datewidget import (
22    FriendlyDateWidget, FriendlyDateDisplayWidget,
23    FriendlyDatetimeDisplayWidget)
24from waeup.kofa.widgets.phonewidget import PhoneWidget
25from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
26    OnlinePaymentCallbackPage, ExportPDFPage,
27    ApplicantManageFormPage, ApplicantEditFormPage)
28from waeup.kofa.applicants.viewlets import RequestCallbackActionButton
29from waeup.kofa.applicants.pdf import PDFApplicationSlip
30from waeup.uniben.applicants.interfaces import (
31    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit)
32from waeup.uniben.interfaces import MessageFactory as _
33
34class RequestCallbackActionButton(RequestCallbackActionButton):
35    """ Do not display the base package callback button in custom pages.
36    """
37    @property
38    def target_url(self):
39        return ''
40
41class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
42    """ Neutralize callback simulation view
43    """
44    def update(self):
45        return
46
47class PDFApplicationSlip(PDFApplicationSlip):
48
49    @property
50    def form_fields(self):
51        target = getattr(self.context.__parent__, 'prefix', None)
52        if target is not None and target.startswith('pg'):
53            form_fields = grok.AutoFields(IPGApplicant).omit(
54                'locked', 'course_admitted')
55        else:
56            form_fields = grok.AutoFields(IUGApplicant).omit(
57                'locked', 'course_admitted')
58        form_fields[
59            'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
60        return form_fields
61
62class ApplicantDisplayFormPage(ApplicantDisplayFormPage):
63    """A display view for applicant data.
64    """
65
66    @property
67    def form_fields(self):
68        target = getattr(self.context.__parent__, 'prefix', None)
69        if target is not None and target.startswith('pg'):
70            form_fields = grok.AutoFields(IPGApplicant).omit(
71                'locked', 'course_admitted', 'password')
72        else:
73            form_fields = grok.AutoFields(IUGApplicant).omit(
74                'locked', 'course_admitted', 'password')
75        form_fields[
76            'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
77        return form_fields
78
79class ApplicantManageFormPage(ApplicantManageFormPage):
80    """A full edit view for applicant data.
81    """
82   
83    @property
84    def form_fields(self):
85        target = getattr(self.context.__parent__, 'prefix', None)
86        if target is not None and target.startswith('pg'):
87            form_fields = grok.AutoFields(IPGApplicant)
88            form_fields[
89                'emp_start'].custom_widget = FriendlyDateWidget('le-year')
90            form_fields[
91                'emp_end'].custom_widget = FriendlyDateWidget('le-year')
92            form_fields[
93                'emp2_start'].custom_widget = FriendlyDateWidget('le-year')
94            form_fields[
95                'emp2_end'].custom_widget = FriendlyDateWidget('le-year')
96        else:
97            form_fields = grok.AutoFields(IUGApplicant)
98        form_fields[
99            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
100        form_fields['phone'].custom_widget = PhoneWidget
101        form_fields['student_id'].for_display = True
102        form_fields['applicant_id'].for_display = True
103        form_fields['phone'].custom_widget = PhoneWidget
104        return form_fields
105
106class ApplicantEditFormPage(ApplicantEditFormPage):
107    """An applicant-centered edit view for applicant data.
108    """
109
110    @property
111    def form_fields(self):
112        target = getattr(self.context.__parent__, 'prefix', None)
113        if target is not None and target.startswith('pg'):
114            form_fields = grok.AutoFields(IPGApplicantEdit).omit(
115                'locked', 'course_admitted', 'student_id',
116                'screening_score', 'screening_venue'
117                )
118            form_fields[
119                'emp_start'].custom_widget = FriendlyDateWidget('le-year')
120            form_fields[
121                'emp_end'].custom_widget = FriendlyDateWidget('le-year')
122            form_fields[
123                'emp2_start'].custom_widget = FriendlyDateWidget('le-year')
124            form_fields[
125                'emp2_end'].custom_widget = FriendlyDateWidget('le-year')
126        else:
127            form_fields = grok.AutoFields(IUGApplicantEdit).omit(
128                'locked', 'course_admitted', 'student_id',
129                'screening_score'
130                )
131        form_fields[
132            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
133        form_fields['phone'].custom_widget = PhoneWidget
134        form_fields['applicant_id'].for_display = True
135        form_fields['reg_number'].for_display = True
136        return form_fields
Note: See TracBrowser for help on using the repository browser.