source: main/waeup.custom/trunk/src/waeup/custom/applicants/browser.py @ 8151

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

See previous revision.

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1## $Id: browser.py 8077 2012-04-09 11:07:20Z 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.custom.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.custom.applicants.interfaces import (
31    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit)
32from waeup.custom.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        else:
89            form_fields = grok.AutoFields(IUGApplicant)
90        form_fields[
91            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
92        form_fields['phone'].custom_widget = PhoneWidget
93        form_fields['student_id'].for_display = True
94        form_fields['applicant_id'].for_display = True
95        return form_fields
96
97class ApplicantEditFormPage(ApplicantEditFormPage):
98    """An applicant-centered edit view for applicant data.
99    """
100
101    @property
102    def form_fields(self):
103        target = getattr(self.context.__parent__, 'prefix', None)
104        if target is not None and target.startswith('pg'):
105            form_fields = grok.AutoFields(IPGApplicantEdit).omit(
106                'locked', 'course_admitted', 'student_id',
107                'screening_score', 'reg_number'
108                )
109        else:
110            form_fields = grok.AutoFields(IUGApplicantEdit).omit(
111                'locked', 'course_admitted', 'student_id',
112                'screening_score', 'reg_number'
113                )
114        form_fields[
115            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
116        form_fields['phone'].custom_widget = PhoneWidget
117        form_fields['applicant_id'].for_display = True
118        return form_fields
Note: See TracBrowser for help on using the repository browser.