Ignore:
Timestamp:
13 Jun 2012, 06:32:13 (13 years ago)
Author:
Henrik Bettermann
Message:

Let's better use an adapter for the webservice.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/payment.py

    r8702 r8703  
    2727from waeup.kofa.interfaces import MessageFactory as _
    2828from waeup.kofa.payments import OnlinePayment
     29from waeup.kofa.payments.interfaces import IPaymentWebservice
    2930from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment
    3031from waeup.kofa.utils.helpers import attrs_to_fields
     
    7475        return self.doAfterApplicantPaymentApproval()
    7576
    76     def getOwner(self):
    77         """Return applicant.
    78         """
    79         return self.__parent__
     77ApplicantOnlinePayment = attrs_to_fields(ApplicantOnlinePayment)
    8078
    81 ApplicantOnlinePayment = attrs_to_fields(ApplicantOnlinePayment)
     79class PaymentWebservice(grok.Adapter):
     80    """An adapter to publish applicant data through a webservice.
     81    """
     82    grok.context(IApplicantOnlinePayment)
     83    grok.implements(IPaymentWebservice)
     84
     85    @property
     86    def payee(self):
     87        return self.context.__parent__.display_fullname
    8288
    8389# Applicant online payments must be importable. So we might need a factory.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8702 r8703  
    3535from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3636from waeup.kofa.app import University
     37from waeup.kofa.payments.interfaces import IPaymentWebservice
    3738from waeup.kofa.configuration import SessionConfiguration
    3839from waeup.kofa.applicants.container import ApplicantsContainer
     
    730731        self.assertEqual(payment.p_category,'application')
    731732        self.assertEqual(payment.amount_auth,200.0)
    732         # Applicant is owner of the payment ticket.
    733         self.assertEqual(payment.getOwner(), self.applicant)
     733        # Applicant is payee of the payment ticket.
     734        self.assertEqual(IPaymentWebservice(payment).payee, 'John Tester')
    734735        # The pdf payment slip can't yet be opened
    735736        #self.browser.open(payment_url + '/payment_receipt.pdf')
  • main/waeup.kofa/trunk/src/waeup/kofa/payments/interfaces.py

    r8702 r8703  
    9393        )
    9494
    95     def getOwner():
    96         "Payments usually have an owner."
    97 
    98 
    9995class ISCPayment(IPayment):
    10096    """A scratch card payment.
     
    144140    def approve():
    145141        "Approve an online payment and set to paid."
     142
     143class IPaymentWebservice(IKofaObject):
     144    """An interface for a webservice.
     145
     146    """
     147
     148    def payee():
     149        "Payments are usually paid by a payee."
  • main/waeup.kofa/trunk/src/waeup/kofa/payments/payment.py

    r8702 r8703  
    5252        return payment_categories.getTermByToken(self.p_category).title
    5353
    54     def getOwner(self):
    55         "Payments usually have an owner."
    56         return None
    57 
    5854# not used
    5955class SCPayment(Payment):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r8702 r8703  
    2626    IStudentPaymentsContainer, IStudentNavigation, IStudentOnlinePayment)
    2727from waeup.kofa.payments import PaymentsContainer, OnlinePayment
     28from waeup.kofa.payments.interfaces import IPaymentWebservice
    2829from waeup.kofa.utils.helpers import attrs_to_fields
    2930from waeup.kofa.accesscodes import create_accesscode
     
    5960        except AttributeError:
    6061            return None
    61 
    62     def getOwner(self):
    63         return self.getStudent()
    6462
    6563    def doAfterStudentPayment(self):
     
    132130StudentOnlinePayment = attrs_to_fields(StudentOnlinePayment)
    133131
     132class PaymentWebservice(grok.Adapter):
     133    """An adapter to publish student data through a webservice.
     134    """
     135    grok.context(IStudentOnlinePayment)
     136    grok.implements(IPaymentWebservice)
     137
     138    @property
     139    def payee(self):
     140        return self.context.getStudent().display_fullname
     141
    134142# Student online payments must be importable. So we might need a factory.
    135143class StudentOnlinePaymentFactory(grok.GlobalUtility):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8702 r8703  
    3636from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3737from waeup.kofa.app import University
     38from waeup.kofa.payments.interfaces import IPaymentWebservice
    3839from waeup.kofa.students.student import Student
    3940from waeup.kofa.students.studylevel import StudentStudyLevel
     
    14731474        self.assertEqual(self.student['payments'][value].p_level, 200)
    14741475
    1475         # Student is owner of the payment ticket.
    1476         self.assertEqual(self.student['payments'][value].getOwner(), self.student)
     1476        # Student is the payee of the payment ticket.
     1477        self.assertEqual(IPaymentWebservice(
     1478            self.student['payments'][value]).payee, 'Anna Tester')
    14771479
    14781480        # We simulate the approval
Note: See TracChangeset for help on using the changeset viewer.