## $Id: payments.py 17963 2024-11-26 02:34:19Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """ Student payment components. """ import grok from zope.component.interfaces import IFactory from zope.interface import implementedBy from waeup.kofa.students.interfaces import IStudentNavigation from waeup.kofa.utils.helpers import attrs_to_fields from kofacustom.nigeria.students.payments import ( NigeriaStudentOnlinePayment, NigeriaStudentOnlinePaymentFactory) from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment from waeup.uniben.interfaces import MessageFactory as _ class CustomStudentOnlinePayment(NigeriaStudentOnlinePayment): """This is a custom online payment for students. Since this class inherits from StudentOnlinePayment, it automatically implements the interfaces of the parent class which means all viewlets and views meant for StudentOnlinePayment can also be accessed in the customized system. """ grok.implements(ICustomStudentOnlinePayment, IStudentNavigation) grok.provides(ICustomStudentOnlinePayment) def __init__(self): super(CustomStudentOnlinePayment, self).__init__() return @property def student(self): return self.__parent__.__parent__ def doAfterStudentPayment(self): """Process student after payment was made. """ if self.p_current: error = self.redeemTicket() if error is not None: return 'danger', error, error # Uniben allows also previous session students to book a bed if self.p_category == 'bed_allocation': error = self.redeemTicket() if error is not None: return 'danger', error, error log = 'successful %s payment: %s' % (self.p_category, self.p_id) msg = _('Payment successfully completed') if self.p_category in ('schoolfee', 'schoolfee_1'): msg += _('. Please proceed to library clearance, register your ' 'courses online and proceed to your ' 'level course adviser for validation.') flashtype = 'success' return flashtype, msg, log CustomStudentOnlinePayment = attrs_to_fields( CustomStudentOnlinePayment, omit=['display_item']) class CustomStudentOnlinePaymentFactory(NigeriaStudentOnlinePaymentFactory): """A factory for student online payments. """ def __call__(self, *args, **kw): return CustomStudentOnlinePayment() def getInterfaces(self): return implementedBy(CustomStudentOnlinePayment)