source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py @ 8263

Last change on this file since 8263 was 8263, checked in by Henrik Bettermann, 13 years ago

Remove surcharge configuration completely.

Implement application fee and school fee payments via Interswitch (part 3)

  • Property svn:keywords set to Id
File size: 6.4 KB
Line 
1## $Id: browser.py 8263 2012-04-24 15:37:51Z henrik $
2##
3## Copyright (C) 2011 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##
18"""UI components for basic applicants and related components.
19"""
20import grok
21from zope.component import getUtility
22from zope.i18n import translate
23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
24from waeup.kofa.students.interfaces import IStudentsUtils
25from waeup.kofa.applicants.interfaces import (
26    IApplicantRegisterUpdate, IApplicant, IApplicantEdit)
27from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
28    OnlinePaymentCallbackPage, ExportPDFPage,
29    ApplicantManageFormPage, ApplicantEditFormPage,
30    ApplicantRegistrationPage, ApplicantAddFormPage,
31    OnlinePaymentDisplayFormPage, ApplicationFeePaymentAddPage,
32    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
33    ApplicantBaseDisplayFormPage)
34from waeup.kofa.applicants.viewlets import (
35    RequestCallbackActionButton, PaymentReceiptActionButton)
36from waeup.kofa.applicants.pdf import PDFApplicationSlip
37from waeup.uniben.applicants.interfaces import (
38    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit,
39    ICustomApplicantOnlinePayment)
40from waeup.uniben.interfaces import MessageFactory as _
41
42#class RequestCallbackActionButton(RequestCallbackActionButton):
43#    """ Display the base package callback button in custom pages.
44#    """
45#    grok.context(ICustomApplicantOnlinePayment)
46
47#class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
48#    """ Activate callback simulation view
49#    """
50#    grok.context(ICustomApplicantOnlinePayment)
51
52class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
53    """A breadcrumb for payments.
54    """
55    grok.context(ICustomApplicantOnlinePayment)
56
57class PaymentReceiptActionButton(PaymentReceiptActionButton):
58    grok.order(4)
59    grok.context(ICustomApplicantOnlinePayment)
60
61class CustomPDFApplicationSlip(PDFApplicationSlip):
62
63    @property
64    def form_fields(self):
65        target = getattr(self.context.__parent__, 'prefix', None)
66        if target is not None and target.startswith('pg'):
67            form_fields = grok.AutoFields(IPGApplicant).omit(
68                'locked', 'course_admitted')
69        else:
70            form_fields = grok.AutoFields(IUGApplicant).omit(
71                'locked', 'course_admitted')
72        return form_fields
73
74class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
75    """A display view for applicant data.
76    """
77
78    @property
79    def form_fields(self):
80        target = getattr(self.context.__parent__, 'prefix', None)
81        if target is not None and target.startswith('pg'):
82            form_fields = grok.AutoFields(IPGApplicant).omit(
83                'locked', 'course_admitted', 'password')
84        else:
85            form_fields = grok.AutoFields(IUGApplicant).omit(
86                'locked', 'course_admitted', 'password')
87        return form_fields
88
89class CustomApplicantManageFormPage(ApplicantManageFormPage):
90    """A full edit view for applicant data.
91    """
92   
93    @property
94    def form_fields(self):
95        target = getattr(self.context.__parent__, 'prefix', None)
96        if target is not None and target.startswith('pg'):
97            form_fields = grok.AutoFields(IPGApplicant)
98        else:
99            form_fields = grok.AutoFields(IUGApplicant)
100        form_fields['student_id'].for_display = True
101        form_fields['applicant_id'].for_display = True
102        return form_fields
103
104class CustomApplicantEditFormPage(ApplicantEditFormPage):
105    """An applicant-centered edit view for applicant data.
106    """
107
108    @property
109    def form_fields(self):
110        target = getattr(self.context.__parent__, 'prefix', None)
111        if target is not None and target.startswith('pg'):
112            form_fields = grok.AutoFields(IPGApplicantEdit).omit(
113                'locked', 'course_admitted', 'student_id',
114                'screening_score', 'screening_venue'
115                )
116        else:
117            form_fields = grok.AutoFields(IUGApplicantEdit).omit(
118                'locked', 'course_admitted', 'student_id',
119                'screening_score'
120                )
121        form_fields['applicant_id'].for_display = True
122        form_fields['reg_number'].for_display = True
123        return form_fields
124
125class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
126    """ Page to view an online payment ticket
127    """
128    grok.context(ICustomApplicantOnlinePayment)
129    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
130    form_fields[
131        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
132    form_fields[
133        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
134    grok.template('payment_view')
135
136    @property
137    def transaction_code(self):
138        tcode = self.context.p_id
139        return tcode[len(tcode)-8:len(tcode)]
140
141class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
142    """ Page to add an online payment ticket
143    """
144    factory = u'waeup.CustomApplicantOnlinePayment'
145
146    def _fillCustomFields(self, payment, session_config):
147        # No custom fields at the moment
148        return payment
149
150class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
151    """Deliver a PDF slip of the context.
152    """
153    grok.context(ICustomApplicantOnlinePayment)
154    form_fields = grok.AutoFields(ICustomApplicantOnlinePayment)
155    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
156    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
157
158    @property
159    def note(self):
160        tcode = self.context.p_id
161        tcode = tcode[len(tcode)-8:len(tcode)]
162        amount = self.context.amount_auth
163        note = translate(_(
164            u"""<br /><br /><br />
165The tranzaction code for eTranzact payments is <strong>${a}</strong>.""",
166            mapping = {'a':tcode}))
167        return note
Note: See TracBrowser for help on using the repository browser.