1 | ## $Id: browser.py 10800 2013-11-28 09:23:57Z 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 hurry.workflow.interfaces import IWorkflowState |
---|
22 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
23 | from waeup.kofa.applicants.browser import ( |
---|
24 | ApplicantRegistrationPage, ApplicantsContainerPage) |
---|
25 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
26 | from kofacustom.ekodisco.applicants.interfaces import ( |
---|
27 | ICustomApplicant, ICustomApplicantEdit) |
---|
28 | from kofacustom.nigeria.applicants.browser import ( |
---|
29 | NigeriaApplicantDisplayFormPage, |
---|
30 | ApplicantDisplayFormPage, |
---|
31 | ApplicantManageFormPage, |
---|
32 | ApplicantEditFormPage) |
---|
33 | |
---|
34 | |
---|
35 | from kofacustom.ekodisco.applicants.workflow import STARTED |
---|
36 | |
---|
37 | from kofacustom.ekodisco.interfaces import MessageFactory as _ |
---|
38 | |
---|
39 | class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
40 | """A display view for applicant data. |
---|
41 | """ |
---|
42 | grok.template('applicantdisplaypage') |
---|
43 | |
---|
44 | form_fields = grok.AutoFields(ICustomApplicant).omit( |
---|
45 | 'locked', 'course_admitted', 'password', 'suspended', |
---|
46 | 'course2', 'notice', 'student_id', 'sex') |
---|
47 | |
---|
48 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
49 | form_fields['service_address'].custom_widget = BytesDisplayWidget |
---|
50 | |
---|
51 | class CustomApplicantManageFormPage(ApplicantManageFormPage): |
---|
52 | """A full edit view for applicant data. |
---|
53 | """ |
---|
54 | grok.template('applicanteditpage') |
---|
55 | |
---|
56 | form_fields = grok.AutoFields(ICustomApplicant).omit( |
---|
57 | 'course2', 'notice', 'student_id', 'sex') |
---|
58 | form_fields['applicant_id'].for_display = True |
---|
59 | |
---|
60 | class CustomApplicantEditFormPage(ApplicantEditFormPage): |
---|
61 | """An applicant-centered edit view for applicant data. |
---|
62 | """ |
---|
63 | grok.template('applicanteditpage') |
---|
64 | |
---|
65 | form_fields = grok.AutoFields(ICustomApplicantEdit).omit( |
---|
66 | 'locked', 'course_admitted', 'student_id', |
---|
67 | 'suspended', 'course2', 'notice', 'sex' |
---|
68 | ) |
---|
69 | form_fields['applicant_id'].for_display = True |
---|
70 | form_fields['reg_number'].for_display = True |
---|
71 | |
---|
72 | submit_state = STARTED |
---|
73 | |
---|
74 | @property |
---|
75 | def display_actions(self): |
---|
76 | state = IWorkflowState(self.context).getState() |
---|
77 | actions = [[],[]] |
---|
78 | if state == STARTED: |
---|
79 | actions = [[_('Save'), _('Final Submit')], []] |
---|
80 | return actions |
---|
81 | |
---|
82 | class CustomPDFApplicationSlip(PDFApplicationSlip): |
---|
83 | """Bypass NigeriaPDFApplicationSlip |
---|
84 | """ |
---|