## $Id: payments.py 8247 2012-04-22 12:56:07Z 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.payments import PaymentsContainer, OnlinePayment
from waeup.kofa.utils.helpers import attrs_to_fields
from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment

class CustomStudentOnlinePayment(OnlinePayment):
    """This is an online payment.
    """
    grok.implements(ICustomStudentOnlinePayment, IStudentNavigation)
    grok.provides(ICustomStudentOnlinePayment)

    def __init__(self):
        super(CustomStudentOnlinePayment, self).__init__()
        return

    def getStudent(self):
        return self.__parent__.__parent__

CustomStudentOnlinePayment = attrs_to_fields(CustomStudentOnlinePayment)

# Student online payments must be importable. So we might need a factory.
class CustomStudentOnlinePaymentFactory(grok.GlobalUtility):
    """A factory for student online payments.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.CustomStudentOnlinePayment')
    title = u"Create a new online payment.",
    description = u"This factory instantiates new online payment instances."

    def __call__(self, *args, **kw):
        return CustomStudentOnlinePayment()

    def getInterfaces(self):
        return implementedBy(CustomStudentOnlinePayment)
