1 | ## $Id: browser.py 8187 2012-04-17 06:58:31Z 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 | |
---|
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 | |
---|
48 | class StudentBaseManageFormPage(StudentBaseManageFormPage): |
---|
49 | """ View to manage student base data |
---|
50 | """ |
---|
51 | form_fields = grok.AutoFields(IStudentBase).omit('student_id') |
---|
52 | |
---|
53 | class StudentBaseEditFormPage(StudentBaseEditFormPage): |
---|
54 | """ View to edit student base data |
---|
55 | """ |
---|
56 | form_fields = grok.AutoFields(IStudentBase).select( |
---|
57 | 'email', 'phone') |
---|
58 | |
---|
59 | |
---|
60 | class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage): |
---|
61 | """ Page to display student personal data |
---|
62 | """ |
---|
63 | grok.context(IStudent) |
---|
64 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
65 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
66 | |
---|
67 | |
---|
68 | class StudentPersonalEditFormPage(StudentPersonalEditFormPage): |
---|
69 | """ Page to edit personal data |
---|
70 | """ |
---|
71 | form_fields = grok.AutoFields(IStudentPersonal) |
---|
72 | |
---|
73 | |
---|
74 | class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage): |
---|
75 | """ Page to display student clearance data |
---|
76 | """ |
---|
77 | grok.context(IStudent) |
---|
78 | |
---|
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'): |
---|
83 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
84 | else: |
---|
85 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
86 | return form_fields |
---|
87 | |
---|
88 | class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage): |
---|
89 | """Deliver a PDF slip of the context. |
---|
90 | """ |
---|
91 | grok.context(IStudent) |
---|
92 | |
---|
93 | @property |
---|
94 | def form_fields(self): |
---|
95 | cm = getattr(self.context,'current_mode', None) |
---|
96 | if cm is not None and cm.startswith('pg'): |
---|
97 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
98 | else: |
---|
99 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
100 | return form_fields |
---|
101 | |
---|
102 | class StudentClearanceManageFormPage(StudentClearanceManageFormPage): |
---|
103 | """ Page to edit student clearance data |
---|
104 | """ |
---|
105 | grok.context(IStudent) |
---|
106 | |
---|
107 | @property |
---|
108 | def form_fields(self): |
---|
109 | cm = getattr(self.context,'current_mode', None) |
---|
110 | if cm is not None and cm.startswith('pg'): |
---|
111 | form_fields = grok.AutoFields(IPGStudentClearance) |
---|
112 | else: |
---|
113 | form_fields = grok.AutoFields(IUGStudentClearance) |
---|
114 | return form_fields |
---|
115 | |
---|
116 | class StudentClearanceEditFormPage(StudentClearanceEditFormPage): |
---|
117 | """ View to edit student clearance data by student |
---|
118 | """ |
---|
119 | grok.context(IStudent) |
---|
120 | |
---|
121 | @property |
---|
122 | def form_fields(self): |
---|
123 | cm = getattr(self.context,'current_mode', None) |
---|
124 | if cm is not None and cm.startswith('pg'): |
---|
125 | form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') |
---|
126 | else: |
---|
127 | form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') |
---|
128 | return form_fields |
---|
129 | |
---|
130 | def dataNotComplete(self): |
---|
131 | store = getUtility(IExtFileStore) |
---|
132 | if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'): |
---|
133 | return _('No birth certificate uploaded.') |
---|
134 | if not store.getFileByContext(self.context, attr=u'ref_let.jpg'): |
---|
135 | return _('No referee letter uploaded.') |
---|
136 | if not store.getFileByContext(self.context, attr=u'acc_let.jpg'): |
---|
137 | return _('No acceptance letter uploaded.') |
---|
138 | if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'): |
---|
139 | return _('No first sitting result uploaded.') |
---|
140 | return False |
---|
141 | |
---|