[7505] | 1 | ## $Id: browser.py 8204 2012-04-18 06:05:16Z 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 |
---|
[8137] | 20 | from zope.component import getUtility |
---|
| 21 | from waeup.kofa.interfaces import IExtFileStore |
---|
[7822] | 22 | from waeup.kofa.students.browser import ( |
---|
[8129] | 23 | StudentPersonalDisplayFormPage, |
---|
[7525] | 24 | StudentClearanceManageFormPage, StudentClearanceEditFormPage, |
---|
[7998] | 25 | StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage, |
---|
[8076] | 26 | ExportPDFClearanceSlipPage, StudentBaseManageFormPage, |
---|
[8140] | 27 | StudentBaseEditFormPage, StudentPersonalEditFormPage) |
---|
[7879] | 28 | from waeup.kofa.students.viewlets import RequestCallbackActionButton |
---|
[8020] | 29 | from waeup.uniben.students.interfaces import ( |
---|
[8204] | 30 | ICustomStudentBase, ICustomStudent, ICustomStudentPersonal, |
---|
| 31 | ICustomUGStudentClearance,ICustomPGStudentClearance, |
---|
[7879] | 32 | ) |
---|
[8020] | 33 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[7505] | 34 | |
---|
[8204] | 35 | class CustomRequestCallbackActionButton(RequestCallbackActionButton): |
---|
[7998] | 36 | """ Do not display the base package callback button in custom pages. |
---|
| 37 | """ |
---|
| 38 | @property |
---|
| 39 | def target_url(self): |
---|
| 40 | return '' |
---|
| 41 | |
---|
[8204] | 42 | class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
[7998] | 43 | """ Neutralize callback simulation view |
---|
| 44 | """ |
---|
| 45 | def update(self): |
---|
| 46 | return |
---|
| 47 | |
---|
[8204] | 48 | class CustomStudentBaseManageFormPage(StudentBaseManageFormPage): |
---|
[8076] | 49 | """ View to manage student base data |
---|
| 50 | """ |
---|
[8204] | 51 | form_fields = grok.AutoFields(ICustomStudentBase).omit('student_id') |
---|
[8076] | 52 | |
---|
[8204] | 53 | class CustomStudentBaseEditFormPage(StudentBaseEditFormPage): |
---|
[8076] | 54 | """ View to edit student base data |
---|
| 55 | """ |
---|
[8204] | 56 | form_fields = grok.AutoFields(ICustomStudentBase).select( |
---|
[8076] | 57 | 'email', 'phone') |
---|
| 58 | |
---|
| 59 | |
---|
[8204] | 60 | class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
[7505] | 61 | """ Page to display student personal data |
---|
| 62 | """ |
---|
[8204] | 63 | grok.context(ICustomStudent) |
---|
| 64 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
[7505] | 65 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 66 | |
---|
| 67 | |
---|
[8204] | 68 | class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage): |
---|
[8140] | 69 | """ Page to edit personal data |
---|
| 70 | """ |
---|
[8204] | 71 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
[8140] | 72 | |
---|
| 73 | |
---|
[8204] | 74 | class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
[7525] | 75 | """ Page to display student clearance data |
---|
| 76 | """ |
---|
[8204] | 77 | grok.context(ICustomStudent) |
---|
[7525] | 78 | |
---|
[7995] | 79 | @property |
---|
| 80 | def form_fields(self): |
---|
| 81 | cm = getattr(self.context,'current_mode', None) |
---|
| 82 | if cm is not None and cm.startswith('pg'): |
---|
[8204] | 83 | form_fields = grok.AutoFields( |
---|
| 84 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
[7995] | 85 | else: |
---|
[8204] | 86 | form_fields = grok.AutoFields( |
---|
| 87 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
[7995] | 88 | return form_fields |
---|
| 89 | |
---|
[8204] | 90 | class CustomExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage): |
---|
[7995] | 91 | """Deliver a PDF slip of the context. |
---|
| 92 | """ |
---|
[8204] | 93 | grok.context(ICustomStudent) |
---|
[7995] | 94 | |
---|
| 95 | @property |
---|
| 96 | def form_fields(self): |
---|
| 97 | cm = getattr(self.context,'current_mode', None) |
---|
| 98 | if cm is not None and cm.startswith('pg'): |
---|
[8204] | 99 | form_fields = grok.AutoFields( |
---|
| 100 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
[7995] | 101 | else: |
---|
[8204] | 102 | form_fields = grok.AutoFields( |
---|
| 103 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
[7995] | 104 | return form_fields |
---|
| 105 | |
---|
[8204] | 106 | class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
[7525] | 107 | """ Page to edit student clearance data |
---|
| 108 | """ |
---|
[8204] | 109 | grok.context(ICustomStudent) |
---|
[7525] | 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'): |
---|
[8204] | 115 | form_fields = grok.AutoFields(ICustomPGStudentClearance) |
---|
[7995] | 116 | else: |
---|
[8204] | 117 | form_fields = grok.AutoFields(ICustomUGStudentClearance) |
---|
[7995] | 118 | return form_fields |
---|
| 119 | |
---|
[8204] | 120 | class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
[7525] | 121 | """ View to edit student clearance data by student |
---|
| 122 | """ |
---|
[8204] | 123 | grok.context(ICustomStudent) |
---|
[7525] | 124 | |
---|
[7995] | 125 | @property |
---|
| 126 | def form_fields(self): |
---|
| 127 | cm = getattr(self.context,'current_mode', None) |
---|
| 128 | if cm is not None and cm.startswith('pg'): |
---|
[8204] | 129 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit('clearance_locked') |
---|
[7995] | 130 | else: |
---|
[8204] | 131 | form_fields = grok.AutoFields(ICustomUGStudentClearance).omit('clearance_locked') |
---|
[7995] | 132 | return form_fields |
---|
| 133 | |
---|
[8137] | 134 | def dataNotComplete(self): |
---|
| 135 | store = getUtility(IExtFileStore) |
---|
| 136 | if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'): |
---|
| 137 | return _('No birth certificate uploaded.') |
---|
| 138 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
| 139 | return _('No referee letter uploaded.') |
---|
| 140 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
| 141 | return _('No acceptance letter uploaded.') |
---|
| 142 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
| 143 | return _('No first sitting result uploaded.') |
---|
| 144 | return False |
---|
| 145 | |
---|