[8012] | 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 |
---|
[8090] | 21 | from waeup.kofa.applicants.interfaces import ( |
---|
| 22 | IApplicantRegisterUpdate, IApplicant, IApplicantEdit) |
---|
[8012] | 23 | from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, |
---|
[8017] | 24 | OnlinePaymentCallbackPage, ExportPDFPage, |
---|
[8090] | 25 | ApplicantManageFormPage, ApplicantEditFormPage, |
---|
| 26 | ApplicantRegistrationPage, ApplicantAddFormPage) |
---|
[8012] | 27 | from waeup.kofa.applicants.viewlets import RequestCallbackActionButton |
---|
[8017] | 28 | from waeup.kofa.applicants.pdf import PDFApplicationSlip |
---|
[8020] | 29 | from waeup.uniben.applicants.interfaces import ( |
---|
[8017] | 30 | IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) |
---|
[8020] | 31 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8012] | 32 | |
---|
[8196] | 33 | class CustomRequestCallbackActionButton(RequestCallbackActionButton): |
---|
[8012] | 34 | """ Do not display the base package callback button in custom pages. |
---|
| 35 | """ |
---|
| 36 | @property |
---|
| 37 | def target_url(self): |
---|
| 38 | return '' |
---|
| 39 | |
---|
[8196] | 40 | class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
[8012] | 41 | """ Neutralize callback simulation view |
---|
| 42 | """ |
---|
| 43 | def update(self): |
---|
| 44 | return |
---|
| 45 | |
---|
[8196] | 46 | class CustomPDFApplicationSlip(PDFApplicationSlip): |
---|
[8012] | 47 | |
---|
[8017] | 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 |
---|
[8012] | 58 | |
---|
[8196] | 59 | class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage): |
---|
[8017] | 60 | """A display view for applicant data. |
---|
| 61 | """ |
---|
[8012] | 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 | |
---|
[8196] | 74 | class CustomApplicantManageFormPage(ApplicantManageFormPage): |
---|
[8012] | 75 | """A full edit view for applicant data. |
---|
| 76 | """ |
---|
[8017] | 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 |
---|
[8012] | 88 | |
---|
[8196] | 89 | class CustomApplicantEditFormPage(ApplicantEditFormPage): |
---|
[8012] | 90 | """An applicant-centered edit view for applicant data. |
---|
| 91 | """ |
---|
[8017] | 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', |
---|
[8051] | 99 | 'screening_score', 'screening_venue' |
---|
[8017] | 100 | ) |
---|
| 101 | else: |
---|
| 102 | form_fields = grok.AutoFields(IUGApplicantEdit).omit( |
---|
| 103 | 'locked', 'course_admitted', 'student_id', |
---|
[8051] | 104 | 'screening_score' |
---|
[8017] | 105 | ) |
---|
| 106 | form_fields['applicant_id'].for_display = True |
---|
[8051] | 107 | form_fields['reg_number'].for_display = True |
---|
[8017] | 108 | return form_fields |
---|