[7505] | 1 | ## $Id: browser.py 8077 2012-04-09 11:07:20Z 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, |
---|
[8077] | 27 | ExportPDFClearanceSlipPage, StudentBaseManageFormPage, |
---|
| 28 | StudentBaseEditFormPage) |
---|
[7879] | 29 | from waeup.kofa.students.viewlets import RequestCallbackActionButton |
---|
| 30 | from waeup.custom.students.interfaces import ( |
---|
[8077] | 31 | IStudentBase, IStudent, IStudentPersonal, |
---|
[7995] | 32 | IUGStudentClearance,IPGStudentClearance, |
---|
[7879] | 33 | ) |
---|
| 34 | from waeup.custom.interfaces import MessageFactory as _ |
---|
[8077] | 35 | from waeup.custom.widgets.phonewidget import PhoneWidget |
---|
[7505] | 36 | |
---|
[7998] | 37 | class RequestCallbackActionButton(RequestCallbackActionButton): |
---|
| 38 | """ Do not display the base package callback button in custom pages. |
---|
| 39 | """ |
---|
| 40 | @property |
---|
| 41 | def target_url(self): |
---|
| 42 | return '' |
---|
| 43 | |
---|
| 44 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
| 45 | """ Neutralize callback simulation view |
---|
| 46 | """ |
---|
| 47 | def update(self): |
---|
| 48 | return |
---|
| 49 | |
---|
[8077] | 50 | class StudentBaseManageFormPage(StudentBaseManageFormPage): |
---|
| 51 | """ View to manage student base data |
---|
| 52 | """ |
---|
| 53 | form_fields = grok.AutoFields(IStudentBase).omit('student_id') |
---|
| 54 | form_fields['phone'].custom_widget = PhoneWidget |
---|
| 55 | |
---|
| 56 | class StudentBaseEditFormPage(StudentBaseEditFormPage): |
---|
| 57 | """ View to edit student base data |
---|
| 58 | """ |
---|
| 59 | form_fields = grok.AutoFields(IStudentBase).select( |
---|
| 60 | 'email', 'phone') |
---|
| 61 | form_fields['phone'].custom_widget = PhoneWidget |
---|
| 62 | |
---|
[7505] | 63 | class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
| 64 | """ Page to display student personal data |
---|
| 65 | """ |
---|
| 66 | grok.context(IStudent) |
---|
| 67 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
| 68 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 69 | |
---|
[7525] | 70 | class StudentPersonalManageFormPage(StudentPersonalManageFormPage): |
---|
| 71 | """ Page to edit student clearance data |
---|
| 72 | """ |
---|
| 73 | grok.context(IStudent) |
---|
| 74 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
[7505] | 75 | |
---|
[7525] | 76 | class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
| 77 | """ Page to display student clearance data |
---|
| 78 | """ |
---|
| 79 | grok.context(IStudent) |
---|
| 80 | |
---|
[7995] | 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 | |
---|
| 91 | class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage): |
---|
| 92 | """Deliver a PDF slip of the context. |
---|
| 93 | """ |
---|
| 94 | grok.context(IStudent) |
---|
| 95 | |
---|
| 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).omit('clearance_locked') |
---|
| 101 | else: |
---|
| 102 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 103 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 104 | return form_fields |
---|
| 105 | |
---|
[7525] | 106 | class StudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
| 107 | """ Page to edit student clearance data |
---|
| 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) |
---|
| 116 | else: |
---|
| 117 | form_fields = grok.AutoFields(IUGStudentClearance) |
---|
| 118 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 119 | return form_fields |
---|
| 120 | |
---|
[7525] | 121 | class StudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
| 122 | """ View to edit student clearance data by student |
---|
| 123 | """ |
---|
| 124 | grok.context(IStudent) |
---|
| 125 | |
---|
[7995] | 126 | @property |
---|
| 127 | def form_fields(self): |
---|
| 128 | cm = getattr(self.context,'current_mode', None) |
---|
| 129 | if cm is not None and cm.startswith('pg'): |
---|
| 130 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
| 131 | else: |
---|
| 132 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 133 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 134 | return form_fields |
---|
| 135 | |
---|