1 | ## $Id: browser.py 10019 2013-03-12 22:17:52Z 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.i18n import translate |
---|
20 | from zope.component import getUtility |
---|
21 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
22 | from waeup.kofa.interfaces import ADMITTED, IKofaUtils |
---|
23 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
24 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
25 | from waeup.kofa.students.browser import ( |
---|
26 | StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage) |
---|
27 | from kofacustom.nigeria.students.browser import ( |
---|
28 | NigeriaOnlinePaymentDisplayFormPage, |
---|
29 | NigeriaOnlinePaymentAddFormPage, |
---|
30 | NigeriaExportPDFPaymentSlipPage, |
---|
31 | NigeriaStudentClearanceEditFormPage, |
---|
32 | NigeriaExportPDFClearanceSlipPage |
---|
33 | ) |
---|
34 | |
---|
35 | from waeup.fceokene.students.interfaces import ( |
---|
36 | ICustomStudentOnlinePayment, ICustomUGStudentClearance) |
---|
37 | |
---|
38 | class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage): |
---|
39 | """Deliver a PDF Admission slip. |
---|
40 | """ |
---|
41 | |
---|
42 | @property |
---|
43 | def label(self): |
---|
44 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
45 | return translate(_('Admission Letter of'), |
---|
46 | 'waeup.kofa', target_language=portal_language) \ |
---|
47 | + ' %s' % self.context.display_fullname |
---|
48 | |
---|
49 | @property |
---|
50 | def label(self): |
---|
51 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
52 | line0 = '' |
---|
53 | if self.context.student.current_mode.startswith('ug'): |
---|
54 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
55 | line1 = translate(_('Admission Letter of'), |
---|
56 | 'waeup.kofa', target_language=portal_language) \ |
---|
57 | + ' %s' % self.context.display_fullname |
---|
58 | return '%s%s' % (line0, line1) |
---|
59 | |
---|
60 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
61 | """ Page to view an online payment ticket |
---|
62 | """ |
---|
63 | grok.context(ICustomStudentOnlinePayment) |
---|
64 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
65 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
66 | form_fields[ |
---|
67 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
68 | form_fields[ |
---|
69 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
70 | |
---|
71 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
72 | """ Page to add an online payment ticket |
---|
73 | """ |
---|
74 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
75 | 'p_category') |
---|
76 | |
---|
77 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
78 | """Deliver a PDF slip of the context. |
---|
79 | """ |
---|
80 | grok.context(ICustomStudentOnlinePayment) |
---|
81 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
82 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
83 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
84 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
85 | |
---|
86 | class CustomStartClearancePage(StartClearancePage): |
---|
87 | |
---|
88 | @property |
---|
89 | def with_ac(self): |
---|
90 | mode = getattr(self.context, 'current_mode', None) |
---|
91 | if mode and mode.startswith('ug'): |
---|
92 | return True |
---|
93 | return False |
---|
94 | |
---|
95 | class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage): |
---|
96 | """Deliver a PDF slip of the context. |
---|
97 | """ |
---|
98 | |
---|
99 | @property |
---|
100 | def form_fields(self): |
---|
101 | if self.context.is_postgrad: |
---|
102 | form_fields = grok.AutoFields( |
---|
103 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
104 | else: |
---|
105 | form_fields = grok.AutoFields( |
---|
106 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
107 | if not getattr(self.context, 'officer_comment'): |
---|
108 | form_fields = form_fields.omit('officer_comment') |
---|
109 | return form_fields |
---|
110 | |
---|
111 | @property |
---|
112 | def label(self): |
---|
113 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
114 | |
---|
115 | line0 = '' |
---|
116 | if self.context.student.current_mode.startswith('ug'): |
---|
117 | line0 = 'Directorate of Undergraduate Programme\n' |
---|
118 | line1 = translate(_('Clearance Slip of'), |
---|
119 | 'waeup.kofa', target_language=portal_language) \ |
---|
120 | + ' %s' % self.context.display_fullname |
---|
121 | return '%s%s' % (line0, line1) |
---|
122 | |
---|
123 | |
---|
124 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
125 | """ View to edit student clearance data by student |
---|
126 | """ |
---|
127 | |
---|
128 | def dataNotComplete(self): |
---|
129 | return False |
---|
130 | |
---|
131 | class CustomBedTicketAddPage(BedTicketAddPage): |
---|
132 | """ Page to add an online payment ticket |
---|
133 | """ |
---|
134 | buttonname = _('Create bed ticket') |
---|
135 | notice = '' |
---|
136 | with_ac = False |
---|