Changeset 6875


Ignore:
Timestamp:
12 Oct 2011, 19:28:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Add StudentOnlinePayment? class (including factory) which also implements IStudentNavigation.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py

    r6869 r6875  
    2020from datetime import datetime
    2121from grok import index
    22 from zope.component.interfaces import IFactory
    23 from zope.interface import implementedBy
    2422from waeup.sirp.payments.interfaces import (
    2523    IPayment, ISCPayment, IOnlinePayment)
     
    7371
    7472OnlinePayment = attrs_to_fields(OnlinePayment)
    75 
    76 # Online payments must be importable. So we might need a factory.
    77 class OnlinePaymentFactory(grok.GlobalUtility):
    78     """A factory for online payments.
    79     """
    80     grok.implements(IFactory)
    81     grok.name(u'waeup.OnlinePayment')
    82     title = u"Create a new online payment.",
    83     description = u"This factory instantiates new online payment instances."
    84 
    85     def __call__(self, *args, **kw):
    86         return OnlinePayment()
    87 
    88     def getInterfaces(self):
    89         return implementedBy(OnlinePayment)
  • main/waeup.sirp/trunk/src/waeup/sirp/payments/tests.py

    r6866 r6875  
    2222from waeup.sirp.payments.container import PaymentsContainer
    2323from waeup.sirp.payments.payment import (
    24     SCPayment, OnlinePayment, OnlinePaymentFactory)
     24    SCPayment, OnlinePayment)
    2525from waeup.sirp.testing import (FunctionalLayer, FunctionalTestCase)
    2626
     
    6464        self.assertRaises(
    6565            NotImplementedError, container.clear)
    66 
    67 class OnlinePaymentFactoryTest(FunctionalTestCase):
    68 
    69     layer = FunctionalLayer
    70 
    71     def setUp(self):
    72         super(OnlinePaymentFactoryTest, self).setUp()
    73         self.factory = OnlinePaymentFactory()
    74         return
    75 
    76     def tearDown(self):
    77         super(OnlinePaymentFactoryTest, self).tearDown()
    78         return
    79 
    80     def test_factory(self):
    81         obj = self.factory()
    82         assert isinstance(obj, OnlinePayment)
    83 
    84     def test_getInterfaces(self):
    85         implemented_by = self.factory.getInterfaces()
    86         assert implemented_by.isOrExtends(IOnlinePayment)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/payments.py

    r6860 r6875  
    2020from grok import index
    2121from zope.component.interfaces import IFactory
     22from zope.interface import implementedBy
    2223from waeup.sirp.students.interfaces import IStudentPaymentsContainer, IStudentNavigation
    23 from waeup.sirp.payments import PaymentsContainer
     24from waeup.sirp.payments import PaymentsContainer, OnlinePayment
     25from waeup.sirp.payments.interfaces import IOnlinePayment
    2426from waeup.sirp.utils.helpers import attrs_to_fields
    2527
     
    3840
    3941StudentPaymentsContainer = attrs_to_fields(StudentPaymentsContainer)
     42
     43class StudentOnlinePayment(OnlinePayment):
     44    """This is an online payment.
     45    """
     46    grok.implements(IOnlinePayment, IStudentNavigation)
     47    grok.provides(IOnlinePayment)
     48
     49    def __init__(self):
     50        super(StudentOnlinePayment, self).__init__()
     51        p_id = None
     52        return
     53
     54    def getStudent(self):
     55        return self.__parent__.__parent__
     56
     57StudentOnlinePayment = attrs_to_fields(StudentOnlinePayment)
     58
     59# Student online payments must be importable. So we might need a factory.
     60class StudentOnlinePaymentFactory(grok.GlobalUtility):
     61    """A factory for student online payments.
     62    """
     63    grok.implements(IFactory)
     64    grok.name(u'waeup.StudentOnlinePayment')
     65    title = u"Create a new online payment.",
     66    description = u"This factory instantiates new online payment instances."
     67
     68    def __call__(self, *args, **kw):
     69        return StudentOnlinePayment()
     70
     71    def getInterfaces(self):
     72        return implementedBy(StudentOnlinePayment)
Note: See TracChangeset for help on using the changeset viewer.