source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/browser.py @ 15369

Last change on this file since 15369 was 15304, checked in by Henrik Bettermann, 6 years ago

Customize PaymentsManageFormPage?.

  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1## $Id: browser.py 15304 2019-01-24 14:34:09Z 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 zope.security import checkPermission
22from hurry.workflow.interfaces import IWorkflowInfo
23from waeup.kofa.interfaces import ADMITTED, IKofaUtils
24from waeup.kofa.interfaces import MessageFactory as _
25from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
26from waeup.kofa.students.browser import (
27    StartClearancePage, BedTicketAddPage,
28    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage,
29    PaymentsManageFormPage)
30from kofacustom.nigeria.students.browser import (
31    NigeriaOnlinePaymentDisplayFormPage,
32    NigeriaOnlinePaymentAddFormPage,
33    NigeriaExportPDFPaymentSlip,
34    NigeriaStudentClearanceEditFormPage,
35    NigeriaExportPDFClearanceSlip,
36    NigeriaExportPDFCourseRegistrationSlip
37    )
38
39from waeup.fceokene.students.interfaces import (
40    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
41    ICustomStudentStudyLevel)
42
43class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
44    """Deliver a PDF Admission slip.
45    """
46
47    @property
48    def label(self):
49        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
50        return translate(_('Admission Letter of'),
51            'waeup.kofa', target_language=portal_language) \
52            + ' %s' % self.context.display_fullname
53
54    @property
55    def label(self):
56        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
57        line0 = ''
58        if self.context.student.current_mode.startswith('ug'):
59            line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n'
60        line1 = translate(_('Admission Letter of'),
61            'waeup.kofa', target_language=portal_language) \
62            + ' %s' % self.context.display_fullname
63        return '%s%s' % (line0, line1)
64
65class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
66    """ Page to view an online payment ticket
67    """
68    grok.context(ICustomStudentOnlinePayment)
69    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
70        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
71    form_fields[
72        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
73    form_fields[
74        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
75
76class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
77    """ Page to add an online payment ticket
78    """
79    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
80        'p_category')
81
82class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
83    """Deliver a PDF slip of the context.
84    """
85    grok.context(ICustomStudentOnlinePayment)
86    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
87        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
88    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
89    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
90
91    note = '''
92
93
94The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
95'''
96
97class CustomStartClearancePage(StartClearancePage):
98
99    @property
100    def with_ac(self):
101        mode = getattr(self.context, 'current_mode', None)
102        if mode and mode.startswith('ug'):
103            return True
104        return False
105
106class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
107    """Deliver a PDF slip of the context.
108    """
109
110    @property
111    def form_fields(self):
112        if self.context.is_postgrad:
113            form_fields = grok.AutoFields(
114                ICustomPGStudentClearance).omit('clearance_locked')
115        else:
116            form_fields = grok.AutoFields(
117                ICustomUGStudentClearance).omit('clearance_locked')
118        if not getattr(self.context, 'officer_comment'):
119            form_fields = form_fields.omit('officer_comment')
120        return form_fields
121
122    @property
123    def label(self):
124        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
125
126        line0 = ''
127        if self.context.student.current_mode.startswith('ug'):
128            line0 = 'Directorate of Undergraduate Programme\n'
129        line1 = translate(_('Clearance Slip of'),
130            'waeup.kofa', target_language=portal_language) \
131            + ' %s' % self.context.display_fullname
132        return '%s%s' % (line0, line1)
133
134
135class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
136    """ View to edit student clearance data by student
137    """
138
139    def dataNotComplete(self):
140        return False
141
142class CustomBedTicketAddPage(BedTicketAddPage):
143    """ Page to add an online payment ticket
144    """
145    buttonname = _('Create bed ticket')
146    notice = ''
147    with_ac = False
148
149class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
150    """ Page to display student study levels
151    """
152    grok.context(ICustomStudentStudyLevel)
153    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
154    form_fields[
155        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
156
157class CustomExportPDFCourseRegistrationSlip(
158    NigeriaExportPDFCourseRegistrationSlip):
159    """Deliver a PDF slip of the context.
160    """
161    grok.context(ICustomStudentStudyLevel)
162    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
163
164class CustomPaymentsManageFormPage(PaymentsManageFormPage):
165    """ Page to manage the student payments. This manage form page is for
166    both students and students officers. FCEOkene does not allow students
167    to remove any payment ticket.
168    """
169    @property
170    def manage_payments_allowed(self):
171        return checkPermission('waeup.manageStudent', self.context)
Note: See TracBrowser for help on using the repository browser.