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

Last change on this file since 14217 was 13060, checked in by Henrik Bettermann, 9 years ago

Rename views according to changes in base package.

  • Property svn:keywords set to Id
File size: 5.2 KB
RevLine 
[8911]1## $Id: browser.py 13060 2015-06-16 13:34:04Z 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 (
[13060]26    StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlip)
[8911]27from kofacustom.nigeria.students.browser import (
28    NigeriaOnlinePaymentDisplayFormPage,
29    NigeriaOnlinePaymentAddFormPage,
[13060]30    NigeriaExportPDFPaymentSlip,
[9190]31    NigeriaStudentClearanceEditFormPage,
[13060]32    NigeriaExportPDFClearanceSlip
[9190]33    )
[8911]34
[10019]35from waeup.fceokene.students.interfaces import (
36    ICustomStudentOnlinePayment, ICustomUGStudentClearance)
[8911]37
[13060]38class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
[9945]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
[8911]60class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
61    """ Page to view an online payment ticket
62    """
63    grok.context(ICustomStudentOnlinePayment)
[9780]64    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[9986]65        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
[8911]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
[13060]77class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
[8911]78    """Deliver a PDF slip of the context.
79    """
80    grok.context(ICustomStudentOnlinePayment)
[9780]81    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
[9986]82        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
[8911]83    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9156]84    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
85
[10529]86    note = '''
87
88
89The total authorized amount includes an Interswitch transaction charge of 150 Nairas.
90'''
91
[9156]92class CustomStartClearancePage(StartClearancePage):
93
[9953]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
[9156]100
[13060]101class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip):
[10019]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
[9181]130class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
131    """ View to edit student clearance data by student
132    """
133
134    def dataNotComplete(self):
[9190]135        return False
136
[9406]137class CustomBedTicketAddPage(BedTicketAddPage):
[9190]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.