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

Last change on this file since 14612 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
RevLine 
[8911]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
[9945]20from zope.component import getUtility
[9156]21from hurry.workflow.interfaces import IWorkflowInfo
[9945]22from waeup.kofa.interfaces import ADMITTED, IKofaUtils
[9156]23from waeup.kofa.interfaces import MessageFactory as _
[8911]24from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[9945]25from waeup.kofa.students.browser import (
[14591]26    StartClearancePage, BedTicketAddPage,
27    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage)
[8911]28from kofacustom.nigeria.students.browser import (
29    NigeriaOnlinePaymentDisplayFormPage,
30    NigeriaOnlinePaymentAddFormPage,
[13060]31    NigeriaExportPDFPaymentSlip,
[9190]32    NigeriaStudentClearanceEditFormPage,
[14591]33    NigeriaExportPDFClearanceSlip,
34    NigeriaExportPDFCourseRegistrationSlip
[9190]35    )
[8911]36
[10019]37from waeup.fceokene.students.interfaces import (
[14591]38    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
39    ICustomStudentStudyLevel)
[8911]40
[13060]41class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
[9945]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
[8911]63class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
64    """ Page to view an online payment ticket
65    """
66    grok.context(ICustomStudentOnlinePayment)
[9780]67    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[9986]68        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
[8911]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
[13060]80class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
[8911]81    """Deliver a PDF slip of the context.
82    """
83    grok.context(ICustomStudentOnlinePayment)
[9780]84    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[9986]85        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
[8911]86    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9156]87    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
88
[10529]89    note = '''
90
91
92The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
93'''
94
[9156]95class CustomStartClearancePage(StartClearancePage):
96
[9953]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
[9156]103
[13060]104class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
[10019]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
[9181]133class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
134    """ View to edit student clearance data by student
135    """
136
137    def dataNotComplete(self):
[9190]138        return False
139
[9406]140class CustomBedTicketAddPage(BedTicketAddPage):
[9190]141    """ Page to add an online payment ticket
142    """
143    buttonname = _('Create bed ticket')
144    notice = ''
[14591]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.