Changeset 10030


Ignore:
Timestamp:
17 Mar 2013, 08:40:59 (12 years ago)
Author:
Henrik Bettermann
Message:

Use better class names. The PaymentWebservice? adapter is not a webservice. KofaPaymentRequest? is not a request but a view for a simple web service.

We do not publish the data of the payee but of the payer.

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

Legend:

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

    r9984 r10030  
    2727from waeup.kofa.interfaces import MessageFactory as _
    2828from waeup.kofa.payments import OnlinePayment
    29 from waeup.kofa.payments.interfaces import IPaymentWebservice
     29from waeup.kofa.payments.interfaces import IPayer
    3030from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment
    3131from waeup.kofa.utils.helpers import attrs_to_fields
     
    7878    ApplicantOnlinePayment, omit=['display_item'])
    7979
    80 class PaymentWebservice(grok.Adapter):
    81     """An adapter to publish applicant data through a webservice.
     80class Payer(grok.Adapter):
     81    """An adapter to publish applicant data through a simple webservice.
    8282    """
    8383    grok.context(IApplicantOnlinePayment)
    84     grok.implements(IPaymentWebservice)
     84    grok.implements(IPayer)
    8585
    8686    @property
    8787    def display_fullname(self):
    88         "Name of  payee"
     88        "Name of  payer"
    8989        return self.context.__parent__.display_fullname
    9090
    9191    @property
    9292    def id(self):
    93         "Id of payee"
     93        "Id of payer"
    9494        return self.context.__parent__.applicant_id
    9595
    9696    @property
    9797    def reg_number(self):
    98         "Reg number of payee"
     98        "Reg number of payer"
    9999        return self.context.__parent__.reg_number
    100100
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r9929 r10030  
    3737from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3838from waeup.kofa.app import University
    39 from waeup.kofa.payments.interfaces import IPaymentWebservice
     39from waeup.kofa.payments.interfaces import IPayer
    4040from waeup.kofa.configuration import SessionConfiguration
    4141from waeup.kofa.applicants.container import ApplicantsContainer
     
    758758        self.assertEqual(payment.p_category,'application')
    759759        self.assertEqual(payment.amount_auth,200.0)
    760         # Applicant is payee of the payment ticket.
     760        # Applicant is payer of the payment ticket.
    761761        self.assertEqual(
    762             IPaymentWebservice(payment).display_fullname, 'John Anthony Tester')
     762            IPayer(payment).display_fullname, 'John Anthony Tester')
    763763        self.assertEqual(
    764             IPaymentWebservice(payment).id, self.applicant.applicant_id)
    765         self.assertEqual(IPaymentWebservice(payment).faculty, '')
    766         self.assertEqual(IPaymentWebservice(payment).department, '')
     764            IPayer(payment).id, self.applicant.applicant_id)
     765        self.assertEqual(IPayer(payment).faculty, '')
     766        self.assertEqual(IPayer(payment).department, '')
    767767        # The pdf payment slip can't yet be opened
    768768        #self.browser.open(payment_url + '/payment_receipt.pdf')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_payment.py

    r9533 r10030  
    2222from zope.interface import verify
    2323from waeup.kofa.applicants.payment import (
    24     ApplicantOnlinePayment, ApplicantOnlinePaymentFactory, PaymentWebservice)
    25 from waeup.kofa.payments.interfaces import IOnlinePayment, IPaymentWebservice
     24    ApplicantOnlinePayment, ApplicantOnlinePaymentFactory, Payer)
     25from waeup.kofa.payments.interfaces import IOnlinePayment, IPayer
    2626
    2727class ApplicantOnlinePaymentFactoryTest(unittest.TestCase):
     
    3939        assert implemented_by.isOrExtends(IOnlinePayment)
    4040
    41     def test_webservice_interface(self):
    42         verify.verifyClass(IPaymentWebservice, PaymentWebservice)
     41    def test_payer_interface(self):
     42        verify.verifyClass(IPayer, Payer)
  • main/waeup.kofa/trunk/src/waeup/kofa/payments/interfaces.py

    r9984 r10030  
    134134        "Approve an online payment and set to paid."
    135135
    136 class IPaymentWebservice(IKofaObject):
    137     """An interface for a webservice.
     136class IPayer(IKofaObject):
     137    """An interface for an adapter to publish student and applicant data
     138    through a simple webservice.
    138139
    139140    """
    140     display_fullname = Attribute('Name of  payee')
    141     id = Attribute('Id of payee')
    142     reg_number = Attribute('Reg number of payee')
    143     matric_number = Attribute('Matric number of payee')
    144     faculty = Attribute('Faculty of payee')
    145     department = Attribute('Department of payee')
     141    display_fullname = Attribute('Name of  payer')
     142    id = Attribute('Id of payer')
     143    reg_number = Attribute('Reg number of payer')
     144    matric_number = Attribute('Matric number of payer')
     145    faculty = Attribute('Faculty of payer')
     146    department = Attribute('Department of payer')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py

    r9984 r10030  
    2626    IStudentPaymentsContainer, IStudentNavigation, IStudentOnlinePayment)
    2727from waeup.kofa.payments import PaymentsContainer, OnlinePayment
    28 from waeup.kofa.payments.interfaces import IPaymentWebservice
     28from waeup.kofa.payments.interfaces import IPayer
    2929from waeup.kofa.utils.helpers import attrs_to_fields
    3030from waeup.kofa.accesscodes import create_accesscode
     
    142142    StudentOnlinePayment, omit=['display_item'])
    143143
    144 class PaymentWebservice(grok.Adapter):
    145     """An adapter to publish student data through a webservice.
     144class Payer(grok.Adapter):
     145    """An adapter to publish student data through a simple webservice.
    146146    """
    147147    grok.context(IStudentOnlinePayment)
    148     grok.implements(IPaymentWebservice)
     148    grok.implements(IPayer)
    149149
    150150    @property
    151151    def display_fullname(self):
    152         "Name of  payee"
     152        "Name of  payer"
    153153        return self.context.student.display_fullname
    154154
    155155    @property
    156156    def id(self):
    157         "Id of payee"
     157        "Id of payer"
    158158        return self.context.student.student_id
    159159
    160160    @property
    161161    def matric_number(self):
    162         "Matric number or reg number of payee"
     162        "Matric number or reg number of payer"
    163163        return self.context.student.matric_number
    164164
    165165    @property
    166166    def reg_number(self):
    167         "Reg number or reg number of payee"
     167        "Reg number or reg number of payer"
    168168        return self.context.student.reg_number
    169169
    170170    @property
    171171    def faculty(self):
    172         "Faculty of payee"
     172        "Faculty of payer"
    173173        return self.context.student.faccode
    174174
    175175    @property
    176176    def department(self):
    177         "Department of payee"
     177        "Department of payer"
    178178        return self.context.student.depcode
    179179
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10016 r10030  
    3838from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3939from waeup.kofa.app import University
    40 from waeup.kofa.payments.interfaces import IPaymentWebservice
     40from waeup.kofa.payments.interfaces import IPayer
    4141from waeup.kofa.students.interfaces import IStudentsUtils
    4242from waeup.kofa.students.student import Student
     
    23132313        self.assertEqual(self.student['payments'][value].p_level, 200)
    23142314
    2315         # Student is the payee of the payment ticket.
    2316         webservice = IPaymentWebservice(self.student['payments'][value])
    2317         self.assertEqual(webservice.display_fullname, 'Anna Tester')
    2318         self.assertEqual(webservice.id, self.student_id)
    2319         self.assertEqual(webservice.faculty, 'fac1')
    2320         self.assertEqual(webservice.department, 'dep1')
     2315        # Student is the payer of the payment ticket.
     2316        payer = IPayer(self.student['payments'][value])
     2317        self.assertEqual(payer.display_fullname, 'Anna Tester')
     2318        self.assertEqual(payer.id, self.student_id)
     2319        self.assertEqual(payer.faculty, 'fac1')
     2320        self.assertEqual(payer.department, 'dep1')
    23212321
    23222322        # We simulate the approval
     
    27952795
    27962796class PublicPagesTests(StudentsFullSetup):
    2797     # Tests for swebservices
     2797    # Tests for simple webservices
    27982798
    27992799    layer = FunctionalLayer
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_payment.py

    r9533 r10030  
    2323from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    2424from waeup.kofa.students.payments import (
    25     StudentOnlinePayment, StudentOnlinePaymentFactory, PaymentWebservice)
    26 from waeup.kofa.payments.interfaces import IOnlinePayment, IPaymentWebservice
     25    StudentOnlinePayment, StudentOnlinePaymentFactory, Payer)
     26from waeup.kofa.payments.interfaces import IOnlinePayment, IPayer
    2727from waeup.kofa.students.interfaces import IStudentNavigation
    2828
     
    4949        assert implemented_by.isOrExtends(IStudentNavigation)
    5050
    51     def test_webservice_interface(self):
    52         verify.verifyClass(IPaymentWebservice, PaymentWebservice)
     51    def test_payer_interface(self):
     52        verify.verifyClass(IPayer, Payer)
  • main/waeup.kofa/trunk/src/waeup/kofa/webservices.py

    r10007 r10030  
    2020from zope.component import getUtility
    2121from zope.catalog.interfaces import ICatalog
    22 from waeup.kofa.payments.interfaces import IPaymentWebservice
     22from waeup.kofa.payments.interfaces import IPayer
    2323from waeup.kofa.interfaces import IUniversity, academic_sessions_vocab
    2424
    25 # Kofa's webservices to requery payments from outside
     25class PaymentDataWebservice(grok.View):
     26    """A simple webservice to publish payment and payer details on request from
     27    accepted IP addresses without authentication.
    2628
    27 class KofaPaymentRequest(grok.View):
    28 
     29    """
    2930    grok.context(IUniversity)
    3031    grok.name('paymentrequest')
     
    4041        real_ip = self.request.get('HTTP_X_FORWARDED_FOR', None)
    4142        if real_ip:
    42             self.context.logger.info('KofaPaymentRequest called: %s' % real_ip)
     43            self.context.logger.info('PaymentDataWebservice called: %s' % real_ip)
    4344        if real_ip and self.ACCEPTED_IP:
    4445            if real_ip not in  self.ACCEPTED_IP:
     
    5253            return
    5354        try:
    54             owner = IPaymentWebservice(results[0])
     55            owner = IPayer(results[0])
    5556            full_name = owner.display_fullname
    5657            reg_number = owner.reg_number
Note: See TracChangeset for help on using the changeset viewer.