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

Last change on this file since 15192 was 14591, checked in by Henrik Bettermann, 8 years ago

Customize warnCreditsOOR and IStudentStudyLevel.

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