[7505] | 1 | ## $Id: browser.py 8108 2012-04-11 13:52:36Z 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, |
---|
[8076] | 27 | ExportPDFClearanceSlipPage, StudentBaseManageFormPage, |
---|
| 28 | StudentBaseEditFormPage) |
---|
[7879] | 29 | from waeup.kofa.students.viewlets import RequestCallbackActionButton |
---|
[8020] | 30 | from waeup.uniben.students.interfaces import ( |
---|
[8076] | 31 | IStudentBase, IStudent, IStudentPersonal, |
---|
[7995] | 32 | IUGStudentClearance,IPGStudentClearance, |
---|
[7879] | 33 | ) |
---|
[8020] | 34 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8076] | 35 | from waeup.uniben.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 | |
---|
[8076] | 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 | |
---|
| 63 | |
---|
[7505] | 64 | class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
| 65 | """ Page to display student personal data |
---|
| 66 | """ |
---|
| 67 | grok.context(IStudent) |
---|
| 68 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
| 69 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 70 | |
---|
[7525] | 71 | class StudentPersonalManageFormPage(StudentPersonalManageFormPage): |
---|
| 72 | """ Page to edit student clearance data |
---|
| 73 | """ |
---|
| 74 | grok.context(IStudent) |
---|
| 75 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
[7505] | 76 | |
---|
[7525] | 77 | class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
| 78 | """ Page to display student clearance data |
---|
| 79 | """ |
---|
| 80 | grok.context(IStudent) |
---|
| 81 | |
---|
[7995] | 82 | @property |
---|
| 83 | def form_fields(self): |
---|
| 84 | cm = getattr(self.context,'current_mode', None) |
---|
| 85 | if cm is not None and cm.startswith('pg'): |
---|
| 86 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
[8108] | 87 | form_fields['emp_start'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 88 | form_fields['emp_end'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 89 | form_fields['emp2_start'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 90 | form_fields['emp2_end'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
[7995] | 91 | else: |
---|
| 92 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 93 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
[8108] | 94 | form_fields['fst_sit_date'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 95 | form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 96 | form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
| 97 | form_fields['alr_date'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
[7995] | 98 | return form_fields |
---|
| 99 | |
---|
| 100 | class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage): |
---|
| 101 | """Deliver a PDF slip of the context. |
---|
| 102 | """ |
---|
| 103 | grok.context(IStudent) |
---|
| 104 | |
---|
| 105 | @property |
---|
| 106 | def form_fields(self): |
---|
| 107 | cm = getattr(self.context,'current_mode', None) |
---|
| 108 | if cm is not None and cm.startswith('pg'): |
---|
| 109 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
[8108] | 110 | form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 111 | form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 112 | form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 113 | form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
[7995] | 114 | else: |
---|
| 115 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 116 | form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') |
---|
[8108] | 117 | form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 118 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 119 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 120 | form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
[7995] | 121 | return form_fields |
---|
| 122 | |
---|
[7525] | 123 | class StudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
| 124 | """ Page to edit student clearance data |
---|
| 125 | """ |
---|
| 126 | grok.context(IStudent) |
---|
| 127 | |
---|
[7995] | 128 | @property |
---|
| 129 | def form_fields(self): |
---|
| 130 | cm = getattr(self.context,'current_mode', None) |
---|
| 131 | if cm is not None and cm.startswith('pg'): |
---|
| 132 | form_fields = grok.AutoFields(IPGStudentClearance) |
---|
[8108] | 133 | form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 134 | form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 135 | form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 136 | form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
[7995] | 137 | else: |
---|
| 138 | form_fields = grok.AutoFields(IUGStudentClearance) |
---|
| 139 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
[8108] | 140 | form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 141 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 142 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 143 | form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 144 | |
---|
| 145 | |
---|
[7995] | 146 | return form_fields |
---|
| 147 | |
---|
[7525] | 148 | class StudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
| 149 | """ View to edit student clearance data by student |
---|
| 150 | """ |
---|
| 151 | grok.context(IStudent) |
---|
| 152 | |
---|
[7995] | 153 | @property |
---|
| 154 | def form_fields(self): |
---|
| 155 | cm = getattr(self.context,'current_mode', None) |
---|
| 156 | if cm is not None and cm.startswith('pg'): |
---|
| 157 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
[8108] | 158 | form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 159 | form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 160 | form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 161 | form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year') |
---|
[7995] | 162 | else: |
---|
| 163 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
| 164 | form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') |
---|
[8108] | 165 | form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 166 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 167 | form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
| 168 | form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year') |
---|
[7995] | 169 | return form_fields |
---|
| 170 | |
---|