[8012] | 1 | ## $Id: browser.py 8077 2012-04-09 11:07:20Z 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) |
---|
[8077] | 24 | from waeup.custom.widgets.phonewidget import PhoneWidget |
---|
[8012] | 25 | from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, |
---|
[8017] | 26 | OnlinePaymentCallbackPage, ExportPDFPage, |
---|
| 27 | ApplicantManageFormPage, ApplicantEditFormPage) |
---|
[8012] | 28 | from waeup.kofa.applicants.viewlets import RequestCallbackActionButton |
---|
[8017] | 29 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
| 30 | from waeup.custom.applicants.interfaces import ( |
---|
| 31 | IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) |
---|
[8012] | 32 | from waeup.custom.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 | |
---|
[8017] | 47 | class PDFApplicationSlip(PDFApplicationSlip): |
---|
[8012] | 48 | |
---|
[8017] | 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 |
---|
[8012] | 61 | |
---|
| 62 | class ApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
[8017] | 63 | """A display view for applicant data. |
---|
| 64 | """ |
---|
[8012] | 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') |
---|
[8017] | 75 | form_fields[ |
---|
| 76 | 'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
[8012] | 77 | return form_fields |
---|
| 78 | |
---|
| 79 | class ApplicantManageFormPage(ApplicantManageFormPage): |
---|
| 80 | """A full edit view for applicant data. |
---|
| 81 | """ |
---|
[8017] | 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 | else: |
---|
| 89 | form_fields = grok.AutoFields(IUGApplicant) |
---|
| 90 | form_fields[ |
---|
| 91 | 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 92 | form_fields['phone'].custom_widget = PhoneWidget |
---|
| 93 | form_fields['student_id'].for_display = True |
---|
| 94 | form_fields['applicant_id'].for_display = True |
---|
| 95 | return form_fields |
---|
[8012] | 96 | |
---|
[8017] | 97 | class ApplicantEditFormPage(ApplicantEditFormPage): |
---|
[8012] | 98 | """An applicant-centered edit view for applicant data. |
---|
| 99 | """ |
---|
[8017] | 100 | |
---|
| 101 | @property |
---|
| 102 | def form_fields(self): |
---|
| 103 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
| 104 | if target is not None and target.startswith('pg'): |
---|
| 105 | form_fields = grok.AutoFields(IPGApplicantEdit).omit( |
---|
| 106 | 'locked', 'course_admitted', 'student_id', |
---|
| 107 | 'screening_score', 'reg_number' |
---|
| 108 | ) |
---|
| 109 | else: |
---|
| 110 | form_fields = grok.AutoFields(IUGApplicantEdit).omit( |
---|
| 111 | 'locked', 'course_admitted', 'student_id', |
---|
| 112 | 'screening_score', 'reg_number' |
---|
| 113 | ) |
---|
| 114 | form_fields[ |
---|
| 115 | 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 116 | form_fields['phone'].custom_widget = PhoneWidget |
---|
| 117 | form_fields['applicant_id'].for_display = True |
---|
| 118 | return form_fields |
---|