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

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

Use FormattedDate?.

  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1## $Id: browser.py 8184 2012-04-16 22:24:59Z 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.uniben.widgets.phonewidget import PhoneWidget
22from waeup.kofa.applicants.interfaces import (
23    IApplicantRegisterUpdate, IApplicant, IApplicantEdit)
24from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
25    OnlinePaymentCallbackPage, ExportPDFPage,
26    ApplicantManageFormPage, ApplicantEditFormPage,
27    ApplicantRegistrationPage, ApplicantAddFormPage)
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        return form_fields
59
60class ApplicantAddFormPage(ApplicantAddFormPage):
61    """Add-form to add an applicant.
62    """
63    form_fields = grok.AutoFields(IApplicant).select(
64        'firstname', 'middlename', 'lastname',
65        'email', 'phone')
66    form_fields['phone'].custom_widget = PhoneWidget
67
68class ApplicantDisplayFormPage(ApplicantDisplayFormPage):
69    """A display view for applicant data.
70    """
71
72    @property
73    def form_fields(self):
74        target = getattr(self.context.__parent__, 'prefix', None)
75        if target is not None and target.startswith('pg'):
76            form_fields = grok.AutoFields(IPGApplicant).omit(
77                'locked', 'course_admitted', 'password')
78        else:
79            form_fields = grok.AutoFields(IUGApplicant).omit(
80                'locked', 'course_admitted', 'password')
81        return form_fields
82
83class ApplicantManageFormPage(ApplicantManageFormPage):
84    """A full edit view for applicant data.
85    """
86   
87    @property
88    def form_fields(self):
89        target = getattr(self.context.__parent__, 'prefix', None)
90        if target is not None and target.startswith('pg'):
91            form_fields = grok.AutoFields(IPGApplicant)
92        else:
93            form_fields = grok.AutoFields(IUGApplicant)
94        form_fields['phone'].custom_widget = PhoneWidget
95        form_fields['student_id'].for_display = True
96        form_fields['applicant_id'].for_display = True
97        return form_fields
98
99class ApplicantEditFormPage(ApplicantEditFormPage):
100    """An applicant-centered edit view for applicant data.
101    """
102
103    @property
104    def form_fields(self):
105        target = getattr(self.context.__parent__, 'prefix', None)
106        if target is not None and target.startswith('pg'):
107            form_fields = grok.AutoFields(IPGApplicantEdit).omit(
108                'locked', 'course_admitted', 'student_id',
109                'screening_score', 'screening_venue'
110                )
111        else:
112            form_fields = grok.AutoFields(IUGApplicantEdit).omit(
113                'locked', 'course_admitted', 'student_id',
114                'screening_score'
115                )
116        form_fields['phone'].custom_widget = PhoneWidget
117        form_fields['applicant_id'].for_display = True
118        form_fields['reg_number'].for_display = True
119        return form_fields
120
121class ApplicantRegistrationPage(ApplicantRegistrationPage):
122    """Captcha'd registration page for applicants.
123    """
124
125    @property
126    def form_fields(self):
127        form_fields = None
128        if self.context.mode == 'create':
129            form_fields = grok.AutoFields(IApplicantEdit).select(
130                'firstname', 'middlename', 'lastname', 'email', 'phone')
131            form_fields['phone'].custom_widget = PhoneWidget
132        elif self.context.mode == 'update':
133            form_fields = grok.AutoFields(IApplicantRegisterUpdate).select(
134                'firstname','reg_number','email')
135        return form_fields
Note: See TracBrowser for help on using the repository browser.