1 | ## $Id: browser.py 8196 2012-04-17 12:14:03Z 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.applicants.interfaces import ( |
---|
22 | IApplicantRegisterUpdate, IApplicant, IApplicantEdit) |
---|
23 | from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, |
---|
24 | OnlinePaymentCallbackPage, ExportPDFPage, |
---|
25 | ApplicantManageFormPage, ApplicantEditFormPage, |
---|
26 | ApplicantRegistrationPage, ApplicantAddFormPage) |
---|
27 | from waeup.kofa.applicants.viewlets import RequestCallbackActionButton |
---|
28 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
29 | from waeup.uniben.applicants.interfaces import ( |
---|
30 | IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) |
---|
31 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
32 | |
---|
33 | class CustomRequestCallbackActionButton(RequestCallbackActionButton): |
---|
34 | """ Do not display the base package callback button in custom pages. |
---|
35 | """ |
---|
36 | @property |
---|
37 | def target_url(self): |
---|
38 | return '' |
---|
39 | |
---|
40 | class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
41 | """ Neutralize callback simulation view |
---|
42 | """ |
---|
43 | def update(self): |
---|
44 | return |
---|
45 | |
---|
46 | class CustomPDFApplicationSlip(PDFApplicationSlip): |
---|
47 | |
---|
48 | @property |
---|
49 | def form_fields(self): |
---|
50 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
51 | if target is not None and target.startswith('pg'): |
---|
52 | form_fields = grok.AutoFields(IPGApplicant).omit( |
---|
53 | 'locked', 'course_admitted') |
---|
54 | else: |
---|
55 | form_fields = grok.AutoFields(IUGApplicant).omit( |
---|
56 | 'locked', 'course_admitted') |
---|
57 | return form_fields |
---|
58 | |
---|
59 | class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
60 | """A display view for applicant data. |
---|
61 | """ |
---|
62 | |
---|
63 | @property |
---|
64 | def form_fields(self): |
---|
65 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
66 | if target is not None and target.startswith('pg'): |
---|
67 | form_fields = grok.AutoFields(IPGApplicant).omit( |
---|
68 | 'locked', 'course_admitted', 'password') |
---|
69 | else: |
---|
70 | form_fields = grok.AutoFields(IUGApplicant).omit( |
---|
71 | 'locked', 'course_admitted', 'password') |
---|
72 | return form_fields |
---|
73 | |
---|
74 | class CustomApplicantManageFormPage(ApplicantManageFormPage): |
---|
75 | """A full edit view for applicant data. |
---|
76 | """ |
---|
77 | |
---|
78 | @property |
---|
79 | def form_fields(self): |
---|
80 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
81 | if target is not None and target.startswith('pg'): |
---|
82 | form_fields = grok.AutoFields(IPGApplicant) |
---|
83 | else: |
---|
84 | form_fields = grok.AutoFields(IUGApplicant) |
---|
85 | form_fields['student_id'].for_display = True |
---|
86 | form_fields['applicant_id'].for_display = True |
---|
87 | return form_fields |
---|
88 | |
---|
89 | class CustomApplicantEditFormPage(ApplicantEditFormPage): |
---|
90 | """An applicant-centered edit view for applicant data. |
---|
91 | """ |
---|
92 | |
---|
93 | @property |
---|
94 | def form_fields(self): |
---|
95 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
96 | if target is not None and target.startswith('pg'): |
---|
97 | form_fields = grok.AutoFields(IPGApplicantEdit).omit( |
---|
98 | 'locked', 'course_admitted', 'student_id', |
---|
99 | 'screening_score', 'screening_venue' |
---|
100 | ) |
---|
101 | else: |
---|
102 | form_fields = grok.AutoFields(IUGApplicantEdit).omit( |
---|
103 | 'locked', 'course_admitted', 'student_id', |
---|
104 | 'screening_score' |
---|
105 | ) |
---|
106 | form_fields['applicant_id'].for_display = True |
---|
107 | form_fields['reg_number'].for_display = True |
---|
108 | return form_fields |
---|