1 | ## $Id: browser.py 16997 2022-07-06 11:38: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 zope.formlib.textwidgets import BytesDisplayWidget |
---|
22 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
23 | from waeup.kofa.applicants.browser import ( |
---|
24 | ApplicantRegistrationPage, ApplicantsContainerPage, |
---|
25 | ApplicantDisplayFormPage, |
---|
26 | ApplicantManageFormPage, |
---|
27 | ApplicantEditFormPage) |
---|
28 | |
---|
29 | from kofacustom.lpng.applicants.interfaces import ( |
---|
30 | ICustomApplicant, |
---|
31 | ICustomApplicantOnlinePayment, |
---|
32 | ) |
---|
33 | |
---|
34 | from kofacustom.lpng.interfaces import MessageFactory as _ |
---|
35 | |
---|
36 | |
---|
37 | class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
38 | """A display view for applicant data. |
---|
39 | """ |
---|
40 | |
---|
41 | @property |
---|
42 | def form_fields(self): |
---|
43 | form_fields = grok.AutoFields(ICustomApplicant) |
---|
44 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
45 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
46 | if not getattr(self.context, 'student_id'): |
---|
47 | form_fields = form_fields.omit('student_id') |
---|
48 | return form_fields |
---|
49 | |
---|
50 | class CustomPDFApplicationSlip(PDFApplicationSlip): |
---|
51 | |
---|
52 | @property |
---|
53 | def form_fields(self): |
---|
54 | form_fields = grok.AutoFields(ICustomApplicant) |
---|
55 | if not getattr(self.context, 'student_id'): |
---|
56 | form_fields = form_fields.omit('student_id') |
---|
57 | return form_fields |
---|
58 | |
---|
59 | class CustomApplicantManageFormPage(ApplicantManageFormPage): |
---|
60 | """A full edit view for applicant data. |
---|
61 | """ |
---|
62 | |
---|
63 | @property |
---|
64 | def form_fields(self): |
---|
65 | form_fields = grok.AutoFields(ICustomApplicant) |
---|
66 | if not getattr(self.context, 'student_id'): |
---|
67 | form_fields = form_fields.omit('student_id') |
---|
68 | form_fields['applicant_id'].for_display = True |
---|
69 | return form_fields |
---|
70 | |
---|
71 | class CustomApplicantEditFormPage(ApplicantEditFormPage): |
---|
72 | """An applicant-centered edit view for applicant data. |
---|
73 | """ |
---|
74 | |
---|
75 | def unremovable(self, ticket): |
---|
76 | return True |
---|
77 | |
---|
78 | @property |
---|
79 | def form_fields(self): |
---|
80 | form_fields = grok.AutoFields(ICustomApplicant) |
---|
81 | form_fields = form_fields.omit('notice') |
---|
82 | if not getattr(self.context, 'student_id'): |
---|
83 | form_fields = form_fields.omit('student_id') |
---|
84 | form_fields['applicant_id'].for_display = True |
---|
85 | form_fields['reg_number'].for_display = True |
---|
86 | return form_fields |
---|
87 | |
---|