1 | ## $Id: browser.py 8080 2012-04-09 12:42:52Z 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.uniben.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.uniben.applicants.interfaces import ( |
---|
31 | IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) |
---|
32 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
33 | |
---|
34 | class 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 | |
---|
41 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
42 | """ Neutralize callback simulation view |
---|
43 | """ |
---|
44 | def update(self): |
---|
45 | return |
---|
46 | |
---|
47 | class 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 | |
---|
62 | class 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 | |
---|
79 | class 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 | return form_fields |
---|
104 | |
---|
105 | class ApplicantEditFormPage(ApplicantEditFormPage): |
---|
106 | """An applicant-centered edit view for applicant data. |
---|
107 | """ |
---|
108 | |
---|
109 | @property |
---|
110 | def form_fields(self): |
---|
111 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
112 | if target is not None and target.startswith('pg'): |
---|
113 | form_fields = grok.AutoFields(IPGApplicantEdit).omit( |
---|
114 | 'locked', 'course_admitted', 'student_id', |
---|
115 | 'screening_score', 'screening_venue' |
---|
116 | ) |
---|
117 | form_fields[ |
---|
118 | 'emp_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
119 | form_fields[ |
---|
120 | 'emp_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
121 | form_fields[ |
---|
122 | 'emp2_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
123 | form_fields[ |
---|
124 | 'emp2_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
125 | else: |
---|
126 | form_fields = grok.AutoFields(IUGApplicantEdit).omit( |
---|
127 | 'locked', 'course_admitted', 'student_id', |
---|
128 | 'screening_score' |
---|
129 | ) |
---|
130 | form_fields[ |
---|
131 | 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
132 | form_fields['phone'].custom_widget = PhoneWidget |
---|
133 | form_fields['applicant_id'].for_display = True |
---|
134 | form_fields['reg_number'].for_display = True |
---|
135 | return form_fields |
---|