## $Id: payments.py 17730 2024-04-02 20:25:29Z 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 datetime import datetime from zope.component import getUtility from zope.component.interfaces import IFactory from zope.interface import implementedBy from waeup.kofa.interfaces import IKofaUtils from waeup.kofa.students.interfaces import IStudentNavigation from waeup.kofa.students.payments import ( StudentOnlinePayment, StudentOnlinePaymentFactory) from waeup.kofa.utils.helpers import attrs_to_fields, to_timezone from kofacustom.nigeria.students.interfaces import INigeriaStudentOnlinePayment class NigeriaStudentOnlinePayment(StudentOnlinePayment): """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(INigeriaStudentOnlinePayment, IStudentNavigation) grok.provides(INigeriaStudentOnlinePayment) def __init__(self): super(NigeriaStudentOnlinePayment, self).__init__() return @property def student(self): try: return self.__parent__.__parent__ except AttributeError: return None @property def formatted_p_date(self): if isinstance(self.payment_date, datetime): tz = getUtility(IKofaUtils).tzinfo try: timestamp = to_timezone( self.payment_date, tz).strftime("%Y-%m-%d %H:%M:%S") except ValueError: return None return timestamp else: return None NigeriaStudentOnlinePayment = attrs_to_fields(NigeriaStudentOnlinePayment, omit=['display_item',]) class NigeriaStudentOnlinePaymentFactory(StudentOnlinePaymentFactory): """A factory for student online payments. """ def __call__(self, *args, **kw): return NigeriaStudentOnlinePayment() def getInterfaces(self): return implementedBy(NigeriaStudentOnlinePayment)