1 | ## $Id: browser.py 8020 2012-04-02 11:05:40Z 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 | """ |
---|
20 | import grok |
---|
21 | from waeup.kofa.widgets.datewidget import ( |
---|
22 | FriendlyDateWidget, FriendlyDateDisplayWidget, |
---|
23 | FriendlyDatetimeDisplayWidget) |
---|
24 | from waeup.kofa.widgets.phonewidget import PhoneWidget |
---|
25 | from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, |
---|
26 | OnlinePaymentCallbackPage, ExportPDFPage, |
---|
27 | ApplicantManageFormPage, ApplicantEditFormPage) |
---|
28 | from waeup.kofa.applicants.viewlets import RequestCallbackActionButton |
---|
29 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
30 | #from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit |
---|
31 | from waeup.uniben.applicants.interfaces import ( |
---|
32 | IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) |
---|
33 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
34 | |
---|
35 | class RequestCallbackActionButton(RequestCallbackActionButton): |
---|
36 | """ Do not display the base package callback button in custom pages. |
---|
37 | """ |
---|
38 | @property |
---|
39 | def target_url(self): |
---|
40 | return '' |
---|
41 | |
---|
42 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
43 | """ Neutralize callback simulation view |
---|
44 | """ |
---|
45 | def update(self): |
---|
46 | return |
---|
47 | |
---|
48 | class PDFApplicationSlip(PDFApplicationSlip): |
---|
49 | |
---|
50 | @property |
---|
51 | def form_fields(self): |
---|
52 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
53 | if target is not None and target.startswith('pg'): |
---|
54 | form_fields = grok.AutoFields(IPGApplicant).omit( |
---|
55 | 'locked', 'course_admitted') |
---|
56 | else: |
---|
57 | form_fields = grok.AutoFields(IUGApplicant).omit( |
---|
58 | 'locked', 'course_admitted') |
---|
59 | form_fields[ |
---|
60 | 'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
61 | return form_fields |
---|
62 | |
---|
63 | class ApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
64 | """A display view for applicant data. |
---|
65 | """ |
---|
66 | |
---|
67 | @property |
---|
68 | def form_fields(self): |
---|
69 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
70 | if target is not None and target.startswith('pg'): |
---|
71 | form_fields = grok.AutoFields(IPGApplicant).omit( |
---|
72 | 'locked', 'course_admitted', 'password') |
---|
73 | else: |
---|
74 | form_fields = grok.AutoFields(IUGApplicant).omit( |
---|
75 | 'locked', 'course_admitted', 'password') |
---|
76 | form_fields[ |
---|
77 | 'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
78 | return form_fields |
---|
79 | |
---|
80 | class ApplicantManageFormPage(ApplicantManageFormPage): |
---|
81 | """A full edit view for applicant data. |
---|
82 | """ |
---|
83 | |
---|
84 | @property |
---|
85 | def form_fields(self): |
---|
86 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
87 | if target is not None and target.startswith('pg'): |
---|
88 | form_fields = grok.AutoFields(IPGApplicant) |
---|
89 | else: |
---|
90 | form_fields = grok.AutoFields(IUGApplicant) |
---|
91 | form_fields[ |
---|
92 | 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
93 | form_fields['phone'].custom_widget = PhoneWidget |
---|
94 | form_fields['student_id'].for_display = True |
---|
95 | form_fields['applicant_id'].for_display = True |
---|
96 | form_fields['phone'].custom_widget = PhoneWidget |
---|
97 | return form_fields |
---|
98 | |
---|
99 | class 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', 'reg_number' |
---|
110 | ) |
---|
111 | else: |
---|
112 | form_fields = grok.AutoFields(IUGApplicantEdit).omit( |
---|
113 | 'locked', 'course_admitted', 'student_id', |
---|
114 | 'screening_score', 'reg_number' |
---|
115 | ) |
---|
116 | form_fields[ |
---|
117 | 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
118 | form_fields['phone'].custom_widget = PhoneWidget |
---|
119 | form_fields['applicant_id'].for_display = True |
---|
120 | return form_fields |
---|