source: main/waeup.fceokene/branches/henrik-diazo-themed/src/waeup/fceokene/students/browser.py @ 11122

Last change on this file since 11122 was 10529, checked in by Henrik Bettermann, 11 years ago

Add note on payment slips.

  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1## $Id: browser.py 10529 2013-08-23 10:38:21Z 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##
18import grok
19from zope.i18n import translate
20from zope.component import getUtility
21from hurry.workflow.interfaces import IWorkflowInfo
22from waeup.kofa.interfaces import ADMITTED, IKofaUtils
23from waeup.kofa.interfaces import MessageFactory as _
24from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
25from waeup.kofa.students.browser import (
26    StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage)
27from kofacustom.nigeria.students.browser import (
28    NigeriaOnlinePaymentDisplayFormPage,
29    NigeriaOnlinePaymentAddFormPage,
30    NigeriaExportPDFPaymentSlipPage,
31    NigeriaStudentClearanceEditFormPage,
32    NigeriaExportPDFClearanceSlipPage
33    )
34
35from waeup.fceokene.students.interfaces import (
36    ICustomStudentOnlinePayment, ICustomUGStudentClearance)
37
38class 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
60class 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
71class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
72    """ Page to add an online payment ticket
73    """
74    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
75        'p_category')
76
77class 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    note = '''
87
88
89The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
90'''
91
92class CustomStartClearancePage(StartClearancePage):
93
94    @property
95    def with_ac(self):
96        mode = getattr(self.context, 'current_mode', None)
97        if mode and mode.startswith('ug'):
98            return True
99        return False
100
101class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage):
102    """Deliver a PDF slip of the context.
103    """
104
105    @property
106    def form_fields(self):
107        if self.context.is_postgrad:
108            form_fields = grok.AutoFields(
109                ICustomPGStudentClearance).omit('clearance_locked')
110        else:
111            form_fields = grok.AutoFields(
112                ICustomUGStudentClearance).omit('clearance_locked')
113        if not getattr(self.context, 'officer_comment'):
114            form_fields = form_fields.omit('officer_comment')
115        return form_fields
116
117    @property
118    def label(self):
119        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
120
121        line0 = ''
122        if self.context.student.current_mode.startswith('ug'):
123            line0 = 'Directorate of Undergraduate Programme\n'
124        line1 = translate(_('Clearance Slip of'),
125            'waeup.kofa', target_language=portal_language) \
126            + ' %s' % self.context.display_fullname
127        return '%s%s' % (line0, line1)
128
129
130class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
131    """ View to edit student clearance data by student
132    """
133
134    def dataNotComplete(self):
135        return False
136
137class CustomBedTicketAddPage(BedTicketAddPage):
138    """ Page to add an online payment ticket
139    """
140    buttonname = _('Create bed ticket')
141    notice = ''
142    with_ac = False
Note: See TracBrowser for help on using the repository browser.