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

Last change on this file since 10519 was 10019, checked in by Henrik Bettermann, 12 years ago

Start customization of clearance slip.

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1## $Id: browser.py 10019 2013-03-12 22:17:52Z 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
86class CustomStartClearancePage(StartClearancePage):
87
88    @property
89    def with_ac(self):
90        mode = getattr(self.context, 'current_mode', None)
91        if mode and mode.startswith('ug'):
92            return True
93        return False
94
95class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage):
96    """Deliver a PDF slip of the context.
97    """
98
99    @property
100    def form_fields(self):
101        if self.context.is_postgrad:
102            form_fields = grok.AutoFields(
103                ICustomPGStudentClearance).omit('clearance_locked')
104        else:
105            form_fields = grok.AutoFields(
106                ICustomUGStudentClearance).omit('clearance_locked')
107        if not getattr(self.context, 'officer_comment'):
108            form_fields = form_fields.omit('officer_comment')
109        return form_fields
110
111    @property
112    def label(self):
113        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
114
115        line0 = ''
116        if self.context.student.current_mode.startswith('ug'):
117            line0 = 'Directorate of Undergraduate Programme\n'
118        line1 = translate(_('Clearance Slip of'),
119            'waeup.kofa', target_language=portal_language) \
120            + ' %s' % self.context.display_fullname
121        return '%s%s' % (line0, line1)
122
123
124class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
125    """ View to edit student clearance data by student
126    """
127
128    def dataNotComplete(self):
129        return False
130
131class CustomBedTicketAddPage(BedTicketAddPage):
132    """ Page to add an online payment ticket
133    """
134    buttonname = _('Create bed ticket')
135    notice = ''
136    with_ac = False
Note: See TracBrowser for help on using the repository browser.