source: main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py @ 8293

Last change on this file since 8293 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: 7.7 KB
RevLine 
[7505]1## $Id: browser.py 8263 2012-04-24 15:37:51Z 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.formlib.textwidgets import BytesDisplayWidget
[8137]20from zope.component import getUtility
[8259]21from zope.i18n import translate
[8247]22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[8137]23from waeup.kofa.interfaces import IExtFileStore
[8247]24from waeup.kofa.browser.layout import action
[7822]25from waeup.kofa.students.browser import (
[8129]26    StudentPersonalDisplayFormPage,
[7525]27    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
[7998]28    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
[8076]29    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
[8247]30    StudentBaseEditFormPage, StudentPersonalEditFormPage,
31    OnlinePaymentDisplayFormPage, OnlinePaymentAddFormPage,
[8259]32    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage)
33from waeup.kofa.students.viewlets import (
34    RequestCallbackActionButton, PaymentReceiptActionButton)
[8020]35from waeup.uniben.students.interfaces import (
[8204]36    ICustomStudentBase, ICustomStudent, ICustomStudentPersonal,
37    ICustomUGStudentClearance,ICustomPGStudentClearance,
[8247]38    ICustomStudentOnlinePayment,
[7879]39    )
[8020]40from waeup.uniben.interfaces import MessageFactory as _
[7505]41
[8259]42#class RequestCallbackActionButton(RequestCallbackActionButton):
43#    """ Display the base package callback button in custom pages.
44#    """
45#    grok.context(ICustomStudentOnlinePayment)
46
47#class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
48#    """ Activate callback simulation view
49#    """
50#    grok.context(ICustomStudentOnlinePayment)
51
[8247]52class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
53    """A breadcrumb for payments.
54    """
55    grok.context(ICustomStudentOnlinePayment)
56
[8259]57class PaymentReceiptActionButton(PaymentReceiptActionButton):
58    grok.order(4)
59    grok.context(ICustomStudentOnlinePayment)
[7998]60
[8204]61class CustomStudentBaseManageFormPage(StudentBaseManageFormPage):
[8076]62    """ View to manage student base data
63    """
[8204]64    form_fields = grok.AutoFields(ICustomStudentBase).omit('student_id')
[8076]65
[8204]66class CustomStudentBaseEditFormPage(StudentBaseEditFormPage):
[8076]67    """ View to edit student base data
68    """
[8204]69    form_fields = grok.AutoFields(ICustomStudentBase).select(
[8076]70        'email', 'phone')
71
72
[8204]73class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
[7505]74    """ Page to display student personal data
75    """
[8204]76    grok.context(ICustomStudent)
77    form_fields = grok.AutoFields(ICustomStudentPersonal)
[7505]78    form_fields['perm_address'].custom_widget = BytesDisplayWidget
79
80
[8204]81class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage):
[8140]82    """ Page to edit personal data
83    """
[8204]84    form_fields = grok.AutoFields(ICustomStudentPersonal)
[8140]85
86
[8204]87class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
[7525]88    """ Page to display student clearance data
89    """
[8204]90    grok.context(ICustomStudent)
[7525]91
[7995]92    @property
93    def form_fields(self):
94        cm = getattr(self.context,'current_mode', None)
95        if cm is not None and cm.startswith('pg'):
[8204]96            form_fields = grok.AutoFields(
97                ICustomPGStudentClearance).omit('clearance_locked')
[7995]98        else:
[8204]99            form_fields = grok.AutoFields(
100                ICustomUGStudentClearance).omit('clearance_locked')
[7995]101        return form_fields
102
[8204]103class CustomExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
[7995]104    """Deliver a PDF slip of the context.
105    """
[8204]106    grok.context(ICustomStudent)
[7995]107
108    @property
109    def form_fields(self):
110        cm = getattr(self.context,'current_mode', None)
111        if cm is not None and cm.startswith('pg'):
[8204]112            form_fields = grok.AutoFields(
113                ICustomPGStudentClearance).omit('clearance_locked')
[7995]114        else:
[8204]115            form_fields = grok.AutoFields(
116                ICustomUGStudentClearance).omit('clearance_locked')
[7995]117        return form_fields
118
[8204]119class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage):
[7525]120    """ Page to edit student clearance data
121    """
[8204]122    grok.context(ICustomStudent)
[7525]123
[7995]124    @property
125    def form_fields(self):
126        cm = getattr(self.context,'current_mode', None)
127        if cm is not None and cm.startswith('pg'):
[8204]128            form_fields = grok.AutoFields(ICustomPGStudentClearance)
[7995]129        else:
[8204]130            form_fields = grok.AutoFields(ICustomUGStudentClearance)
[7995]131        return form_fields
132
[8204]133class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage):
[7525]134    """ View to edit student clearance data by student
135    """
[8204]136    grok.context(ICustomStudent)
[7525]137
[7995]138    @property
139    def form_fields(self):
140        cm = getattr(self.context,'current_mode', None)
141        if cm is not None and cm.startswith('pg'):
[8204]142            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit('clearance_locked')
[7995]143        else:
[8204]144            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit('clearance_locked')
[7995]145        return form_fields
146
[8137]147    def dataNotComplete(self):
148        store = getUtility(IExtFileStore)
149        if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'):
150            return _('No birth certificate uploaded.')
151        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
152            return _('No referee letter uploaded.')
153        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
154            return _('No acceptance letter uploaded.')
155        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
156            return _('No first sitting result uploaded.')
157        return False
158
[8247]159class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
160    """ Page to view an online payment ticket
161    """
162    grok.context(ICustomStudentOnlinePayment)
163    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
164    form_fields[
165        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
166    form_fields[
167        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
168    grok.template('payment_view')
169
170    @property
171    def transaction_code(self):
172        tcode = self.context.p_id
173        return tcode[len(tcode)-8:len(tcode)]
174
175class CustomOnlinePaymentAddFormPage(OnlinePaymentAddFormPage):
176    """ Page to add an online payment ticket
177    """
178    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
179        'p_category')
180    factory = u'waeup.CustomStudentOnlinePayment'
181
182    def _fillCustomFields(self, payment, pay_details):
[8263]183        # No custom fields at the moment
[8247]184        return payment
[8259]185
186class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
187    """Deliver a PDF slip of the context.
188    """
189    grok.context(ICustomStudentOnlinePayment)
190    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
191    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
192    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
193
194    @property
195    def note(self):
196        tcode = self.context.p_id
197        tcode = tcode[len(tcode)-8:len(tcode)]
198        amount = self.context.amount_auth
199        note = translate(_(
200            u"""<br /><br /><br />
201The tranzaction code for eTranzact payments is <strong>${a}</strong>.""",
202            mapping = {'a':tcode}))
203        return note
Note: See TracBrowser for help on using the repository browser.