1 | ## $Id: browser.py 8012 2012-03-30 17:55:44Z 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, ApplicantManageFormPage) |
---|
27 | from waeup.kofa.applicants.viewlets import RequestCallbackActionButton |
---|
28 | from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit |
---|
29 | from waeup.custom.applicants.interfaces import IPGApplicant, IUGApplicant |
---|
30 | from waeup.custom.interfaces import MessageFactory as _ |
---|
31 | |
---|
32 | class RequestCallbackActionButton(RequestCallbackActionButton): |
---|
33 | """ Do not display the base package callback button in custom pages. |
---|
34 | """ |
---|
35 | @property |
---|
36 | def target_url(self): |
---|
37 | return '' |
---|
38 | |
---|
39 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
40 | """ Neutralize callback simulation view |
---|
41 | """ |
---|
42 | def update(self): |
---|
43 | return |
---|
44 | |
---|
45 | class ExportPDFPage(ExportPDFPage): |
---|
46 | """Deliver a PDF slip of the context. |
---|
47 | """ |
---|
48 | grok.context(IApplicant) |
---|
49 | grok.name('application_slip.pdf') |
---|
50 | grok.require('waeup.viewApplication') |
---|
51 | form_fields = grok.AutoFields(IApplicant).omit( |
---|
52 | 'locked', 'course_admitted') |
---|
53 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
54 | prefix = 'form' |
---|
55 | |
---|
56 | |
---|
57 | class ApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
58 | |
---|
59 | @property |
---|
60 | def form_fields(self): |
---|
61 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
62 | if target is not None and target.startswith('pg'): |
---|
63 | form_fields = grok.AutoFields(IPGApplicant).omit( |
---|
64 | 'locked', 'course_admitted', 'password') |
---|
65 | else: |
---|
66 | form_fields = grok.AutoFields(IUGApplicant).omit( |
---|
67 | 'locked', 'course_admitted', 'password') |
---|
68 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
69 | return form_fields |
---|
70 | |
---|
71 | class ApplicantManageFormPage(ApplicantManageFormPage): |
---|
72 | """A full edit view for applicant data. |
---|
73 | """ |
---|
74 | grok.context(IApplicant) |
---|
75 | grok.name('manage') |
---|
76 | grok.require('waeup.manageApplication') |
---|
77 | form_fields = grok.AutoFields(IApplicant) |
---|
78 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
79 | form_fields['student_id'].for_display = True |
---|
80 | form_fields['applicant_id'].for_display = True |
---|
81 | form_fields['phone'].custom_widget = PhoneWidget |
---|
82 | grok.template('applicanteditpage') |
---|
83 | manage_applications = True |
---|
84 | pnav = 3 |
---|
85 | display_actions = [[_('Save'), _('Final Submit')], |
---|
86 | [_('Add online payment ticket'),_('Remove selected tickets')]] |
---|
87 | |
---|
88 | |
---|
89 | class ApplicantEditFormPage(ApplicantManageFormPage): |
---|
90 | """An applicant-centered edit view for applicant data. |
---|
91 | """ |
---|
92 | grok.context(IApplicantEdit) |
---|
93 | grok.name('edit') |
---|
94 | grok.require('waeup.handleApplication') |
---|
95 | form_fields = grok.AutoFields(IApplicantEdit).omit( |
---|
96 | 'locked', 'course_admitted', 'student_id', |
---|
97 | 'screening_score', 'reg_number' |
---|
98 | ) |
---|
99 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
100 | form_fields['phone'].custom_widget = PhoneWidget |
---|
101 | form_fields['applicant_id'].for_display = True |
---|
102 | grok.template('applicanteditpage') |
---|
103 | manage_applications = False |
---|