1 | ## $Id: browser.py 8184 2012-04-16 22:24:59Z 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 |
---|
20 | from zope.component import getUtility |
---|
21 | from waeup.kofa.interfaces import IExtFileStore |
---|
22 | from waeup.kofa.students.browser import ( |
---|
23 | StudentPersonalDisplayFormPage, |
---|
24 | StudentClearanceManageFormPage, StudentClearanceEditFormPage, |
---|
25 | StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage, |
---|
26 | ExportPDFClearanceSlipPage, StudentBaseManageFormPage, |
---|
27 | StudentBaseEditFormPage, StudentPersonalEditFormPage) |
---|
28 | from waeup.kofa.students.viewlets import RequestCallbackActionButton |
---|
29 | from waeup.uniben.students.interfaces import ( |
---|
30 | IStudentBase, IStudent, IStudentPersonal, |
---|
31 | IUGStudentClearance,IPGStudentClearance, |
---|
32 | ) |
---|
33 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
34 | from waeup.uniben.widgets.phonewidget import PhoneWidget |
---|
35 | |
---|
36 | class RequestCallbackActionButton(RequestCallbackActionButton): |
---|
37 | """ Do not display the base package callback button in custom pages. |
---|
38 | """ |
---|
39 | @property |
---|
40 | def target_url(self): |
---|
41 | return '' |
---|
42 | |
---|
43 | class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage): |
---|
44 | """ Neutralize callback simulation view |
---|
45 | """ |
---|
46 | def update(self): |
---|
47 | return |
---|
48 | |
---|
49 | class StudentBaseManageFormPage(StudentBaseManageFormPage): |
---|
50 | """ View to manage student base data |
---|
51 | """ |
---|
52 | form_fields = grok.AutoFields(IStudentBase).omit('student_id') |
---|
53 | form_fields['phone'].custom_widget = PhoneWidget |
---|
54 | |
---|
55 | class StudentBaseEditFormPage(StudentBaseEditFormPage): |
---|
56 | """ View to edit student base data |
---|
57 | """ |
---|
58 | form_fields = grok.AutoFields(IStudentBase).select( |
---|
59 | 'email', 'phone') |
---|
60 | form_fields['phone'].custom_widget = PhoneWidget |
---|
61 | |
---|
62 | |
---|
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 | |
---|
70 | |
---|
71 | class StudentPersonalEditFormPage(StudentPersonalEditFormPage): |
---|
72 | """ Page to edit personal data |
---|
73 | """ |
---|
74 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
75 | |
---|
76 | |
---|
77 | class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
78 | """ Page to display student clearance data |
---|
79 | """ |
---|
80 | grok.context(IStudent) |
---|
81 | |
---|
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') |
---|
87 | else: |
---|
88 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
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 | return form_fields |
---|
104 | |
---|
105 | class StudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
106 | """ Page to edit student clearance data |
---|
107 | """ |
---|
108 | grok.context(IStudent) |
---|
109 | |
---|
110 | @property |
---|
111 | def form_fields(self): |
---|
112 | cm = getattr(self.context,'current_mode', None) |
---|
113 | if cm is not None and cm.startswith('pg'): |
---|
114 | form_fields = grok.AutoFields(IPGStudentClearance) |
---|
115 | else: |
---|
116 | form_fields = grok.AutoFields(IUGStudentClearance) |
---|
117 | return form_fields |
---|
118 | |
---|
119 | class StudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
120 | """ View to edit student clearance data by student |
---|
121 | """ |
---|
122 | grok.context(IStudent) |
---|
123 | |
---|
124 | @property |
---|
125 | def form_fields(self): |
---|
126 | cm = getattr(self.context,'current_mode', None) |
---|
127 | if cm is not None and cm.startswith('pg'): |
---|
128 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
129 | else: |
---|
130 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
131 | return form_fields |
---|
132 | |
---|
133 | def dataNotComplete(self): |
---|
134 | store = getUtility(IExtFileStore) |
---|
135 | if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'): |
---|
136 | return _('No birth certificate uploaded.') |
---|
137 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
138 | return _('No referee letter uploaded.') |
---|
139 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
140 | return _('No acceptance letter uploaded.') |
---|
141 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
142 | return _('No first sitting result uploaded.') |
---|
143 | return False |
---|
144 | |
---|