[7505] | 1 | ## $Id: browser.py 7998 2012-03-28 20:50:45Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2012 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 | import grok |
---|
| 19 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[7822] | 20 | from waeup.kofa.widgets.datewidget import ( |
---|
[7525] | 21 | FriendlyDateWidget, FriendlyDateDisplayWidget |
---|
| 22 | ) |
---|
[7822] | 23 | from waeup.kofa.students.browser import ( |
---|
[7525] | 24 | StudentPersonalDisplayFormPage, StudentPersonalManageFormPage, |
---|
| 25 | StudentClearanceManageFormPage, StudentClearanceEditFormPage, |
---|
[7998] | 26 | StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage, |
---|
[7995] | 27 | ExportPDFClearanceSlipPage) |
---|
[7879] | 28 | from waeup.kofa.students.viewlets import RequestCallbackActionButton |
---|
| 29 | from waeup.custom.students.interfaces import ( |
---|
[7995] | 30 | IStudent, IStudentPersonal, |
---|
| 31 | IUGStudentClearance,IPGStudentClearance, |
---|
[7879] | 32 | ) |
---|
| 33 | from waeup.custom.interfaces import MessageFactory as _ |
---|
[7505] | 34 | |
---|
[7998] | 35 | class RequestCallbackActionButton(RequestCallbackActionButton): |
---|
| 36 | """ Do not display the base package callback button in custom pages. |
---|
| 37 | """ |
---|
| 38 | @property |
---|
| 39 | def target_url(self): |
---|
| 40 | return '' |
---|
| 41 | |
---|
| 42 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
| 43 | """ Neutralize callback simulation view |
---|
| 44 | """ |
---|
| 45 | def update(self): |
---|
| 46 | return |
---|
| 47 | |
---|
[7505] | 48 | class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
| 49 | """ Page to display student personal data |
---|
| 50 | """ |
---|
| 51 | grok.context(IStudent) |
---|
| 52 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
| 53 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 54 | |
---|
[7525] | 55 | class StudentPersonalManageFormPage(StudentPersonalManageFormPage): |
---|
| 56 | """ Page to edit student clearance data |
---|
| 57 | """ |
---|
| 58 | grok.context(IStudent) |
---|
| 59 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
[7505] | 60 | |
---|
[7525] | 61 | class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
| 62 | """ Page to display student clearance data |
---|
| 63 | """ |
---|
| 64 | grok.context(IStudent) |
---|
| 65 | |
---|
[7995] | 66 | @property |
---|
| 67 | def form_fields(self): |
---|
| 68 | cm = getattr(self.context,'current_mode', None) |
---|
| 69 | if cm is not None and cm.startswith('pg'): |
---|
| 70 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
| 71 | else: |
---|
| 72 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 73 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 74 | return form_fields |
---|
| 75 | |
---|
| 76 | class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage): |
---|
| 77 | """Deliver a PDF slip of the context. |
---|
| 78 | """ |
---|
| 79 | grok.context(IStudent) |
---|
| 80 | |
---|
| 81 | @property |
---|
| 82 | def form_fields(self): |
---|
| 83 | cm = getattr(self.context,'current_mode', None) |
---|
| 84 | if cm is not None and cm.startswith('pg'): |
---|
| 85 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
| 86 | else: |
---|
| 87 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 88 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 89 | return form_fields |
---|
| 90 | |
---|
[7525] | 91 | class StudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
| 92 | """ Page to edit student clearance data |
---|
| 93 | """ |
---|
| 94 | grok.context(IStudent) |
---|
| 95 | |
---|
[7995] | 96 | @property |
---|
| 97 | def form_fields(self): |
---|
| 98 | cm = getattr(self.context,'current_mode', None) |
---|
| 99 | if cm is not None and cm.startswith('pg'): |
---|
| 100 | form_fields = grok.AutoFields(IPGStudentClearance) |
---|
| 101 | else: |
---|
| 102 | form_fields = grok.AutoFields(IUGStudentClearance) |
---|
| 103 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 104 | return form_fields |
---|
| 105 | |
---|
[7525] | 106 | class StudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
| 107 | """ View to edit student clearance data by student |
---|
| 108 | """ |
---|
| 109 | grok.context(IStudent) |
---|
| 110 | |
---|
[7995] | 111 | @property |
---|
| 112 | def form_fields(self): |
---|
| 113 | cm = getattr(self.context,'current_mode', None) |
---|
| 114 | if cm is not None and cm.startswith('pg'): |
---|
| 115 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
| 116 | else: |
---|
| 117 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 118 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 119 | return form_fields |
---|
| 120 | |
---|